TTS remaining null - java

TTS object tts is always remaining null.
onInit always shows the toast message failed.
I have tried all other methods of creating onInitlistener as a separate method.
But the status code of onInit always remains -1 ie the value of error.
Please Help!!
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSpeechButton = (Button) findViewById(R.id.speechButton);
mSpeechButton.setEnabled(false);
mSpeechTextView = (TextView) findViewById(R.id.speechText);
// Hide the ActionBar
getActionBar().hide();
tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
// TODO Auto-generated method stub
if (status != TextToSpeech.ERROR) {
tts.setLanguage(Locale.getDefault());
mSpeechButton.setEnabled(true);
mTrue = true;
} else {
mTrue = false;
Toast.makeText(getApplicationContext(), "Failed",
Toast.LENGTH_LONG).show();
}
}
});
mSpeechButton.setOnClickListener(this);
}

package com.example.textspeech;
import java.util.Locale;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
public class MainActivity extends Activity {
TextToSpeech mTextToSpeech;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextToSpeech = new TextToSpeech(getApplicationContext(),
new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
mTextToSpeech.setLanguage(Locale.UK);
mTextToSpeech.speak("You will use Eclipse IDE to create an Android application and name it as TextToSpeech under a package", TextToSpeech.QUEUE_FLUSH, null);
}
});
}
}

Related

Problem in playing audio file using media player

Here is the code for the button which should start and pause the audio.
I have checked the button-text == "start" or "pause" and change the text and use the appropriate methods accordingly
i.e mediaplayer.start() and mediaplayer.pause().
But still, the audio won't play.
package com.example.demo;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity
{
MediaPlayer mediaPlayer;//Mediaplayer
Button button;
public void start(View view)
{
String text = button.getText().toString();
if (text == "start")
{
mediaPlayer.start(); //starting the audio
button.setText("pause");
}
else
{
mediaPlayer.pause(); //pausing the audio
button.setText("start");
}
}
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.start);
mediaPlayer = MediaPlayer.create(this,R.raw.music);
}
}
There are a few steps you should try:
First, try this because I think It gives always a false condition:
if(text.trim().equals("start"))
If Still not work Try this one:
public class MainActivity extends AppCompatActivity
{
MediaPlayer mediaPlayer;//Mediaplayer
Button button;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.start);
mediaPlayer = MediaPlayer.create(this,R.raw.music);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String text = button.getText().toString().trim();
if (text.equals("start"))
{
mediaPlayer.start();
button.setText("pause");
}
else
{
mediaPlayer.pause();
button.setText("start");
}
}
}
} }

Music doesn't play again after I press home or recents button

I have an app with a button to play or pause music. Pressing the back button while playing music pauses it and opening the app again resumes the music after pressing the play button. But that doesn't work with home or recents button. The music pauses but upon reopening the app and pressing the play button doesn't play the music until a force close. Here is the code:
package com.example.firozkaoo2222.myapplication;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import static com.example.firozkaoo2222.myapplication.R.raw.police;
public class MainActivity extends AppCompatActivity {
private MediaPlayer policeSound = MediaPlayer.create(this, police);
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button policeSounds = this.findViewById(R.id.police);
policeSounds.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (policeSound == null) {
policeSound = MediaPlayer.create(getApplicationContext(), R.raw.police);
}
if (policeSound.isPlaying()) {
policeSound.pause();
} else {
policeSound.start();
}
}
});
}
#Override
protected void onResume() {
super.onResume();
if (policeSound != null) {
policeSound = MediaPlayer.create(this, R.raw.police);
policeSound.start();
}
}
#Override
public void onPause() {
super.onPause();
if (policeSound.isPlaying())
policeSound.pause();
}
//Back button pressed.
#Override
public void onBackPressed() {
super.onBackPressed();
if (policeSound.isPlaying())
policeSound.pause();
}
#Override
protected void onDestroy() {
super.onDestroy();
policeSound.stop();
policeSound = null;
}
}
If you press home button the app go to the background and when you came from the background you should override the method onResume();
Code:
public class MainActivity extends AppCompatActivity {
//THIS IS YOUR LAST MISTAKE. IF YOU TRY TO CREATE THE OBJECT WITH THE CONTEXT AND THE RESOUERCES
//WHEN THE ACTIVITY IS NOT CREATED YET, YOUR APP CRASH
//private MediaPlayer policeSound = MediaPlayer.create(this, R.raw.police);
private MediaPlayer policeSound;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button policeSounds = this.findViewById(R.id.police);
policeSounds.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (policeSound == null) {
policeSound = MediaPlayer.create(getApplicationContext(), R.raw.police);
}
if (policeSound.isPlaying()) {
policeSound.pause();
} else {
policeSound.start();
}
}
});
}
#Override
protected void onResume() {
super.onResume();
if (policeSound != null) {
policeSound = MediaPlayer.create(this, R.raw.police);
policeSound.start();
}
}
#Override
public void onPause() {
super.onPause();
if (policeSound.isPlaying())
policeSound.pause();
}
//Back button pressed.
#Override
public void onBackPressed() {
super.onBackPressed();
if (policeSound.isPlaying())
policeSound.pause();
}
#Override
protected void onDestroy() {
super.onDestroy();
policeSound.stop();
policeSound = null;
}
}
I hope this help you.

ShakeActivity 1st launch to be neglected

I wanted to create a webview that comes on shakeactivity. In xml of current activity, I made webview visibility as invisibe. Now, I have this shakeevent listener. Everything is working fine, except I start this shakeactivity on its first launch it displays shaking in toast in text i included that, which i have in onShake() function. But, I dont want that. I want to neglect the first launch of this shakeactivity and after 2nd shake i want to refresh the shakeactivity to load a url and visibility of webview to visible.
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.Toast;
public class MainActivity extends Activity implements
ShakeEventManager.shakeListener {
private ShakeEventManager sd;
private static long back_pressed;
Boolean isInternetPresent = false;
private int count = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
createData();
sd = new ShakeEventManager();
sd.setListener(this);
sd.init(this);
}
private void createData() {
WebView web = (WebView) findViewById(R.id.webview);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setPluginsEnabled(true);
web.loadUrl("http://www.google.com");
}
#Override
public void onShake() {
count++;
if (count >= 1) {
ConnectionDetector cd = new ConnectionDetector(
getApplicationContext());
isInternetPresent = cd.isConnectingToInternet();
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);
if (isInternetPresent) {
createData();
} else {
Toast.makeText(getApplicationContext(),
"Enable Data Connection", Toast.LENGTH_LONG).show();
}
}
}
#Override
public void onResume() {
super.onResume();
sd.register();
}
#Override
protected void onPause() {
super.onPause();
sd.deregister();
}
#Override
public void onBackPressed() {
finish();
}
}
Your count++ variable increasing value first before checking condition first time so that you may have to increase in if as i have done or you can put this statement at the last after condition.
Change like following:
#Override
public void onShake() {
if (count++ >= 1) {
ConnectionDetector cd = new ConnectionDetector(
getApplicationContext());
isInternetPresent = cd.isConnectingToInternet();
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);
if (isInternetPresent) {
createData();
} else {
Toast.makeText(getApplicationContext(),
"Enable Data Connection", Toast.LENGTH_LONG).show();
}
}
}
Note: I dont have tested but i just saw your code and found this
logical mistake so may be helpful to you :)

Android speech Recognition App Without Pop Up

I'm currently looking into getting a career with JAVA and have decided to start by building an app.
I have this code right here that I am using to trigger Speech Recognition.
public class MainActivity extends Activity implements OnClickListener{
private static final int VR_REQUEST = 999;
private ListView wordList;
private final String LOG_TAG = "SpeechRepeatActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speechBtn = (Button) findViewById(R.id.speech_btn);
wordList = (ListView) findViewById (R.id.word_list);
PackageManager packManager= getPackageManager();
List<ResolveInfo> intActivities = packManager.queryIntentActivities
(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (intActivities.size() !=0){
speechBtn.setOnClickListener(this);
} else {
speechBtn.setEnabled(false);
Toast.makeText(this,"Oops - Speech Recognition Not Supported!",
Toast.LENGTH_LONG).show();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onClick(View v){
if (v.getId() == R.id.speech_btn) {
listenToSpeech();
}
}
private void listenToSpeech() {
//start the speech recognition intent passing required data
Intent listenIntent =
new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//indicate package
listenIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
getClass().getPackage().getName());
//message to display while listening
listenIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word!");
//set speech model
listenIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//specify number of results to retrieve
listenIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
//start listening
startActivityForResult(listenIntent, VR_REQUEST);
}
#Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
//check speech recognition result
if (requestCode == VR_REQUEST && resultCode == RESULT_OK) {
//store the returned word list as an ArrayList
ArrayList<String> suggestedWords = data.
getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
//set the retrieved list to display in the ListView
//using an ArrayAdapter
wordList.setAdapter(new ArrayAdapter<String>
(this, R.layout.word, suggestedWords));
}
//this detects which one the user clicks
wordList.setOnItemClickListener(new OnItemClickListener(){
//click listener for items within list
public void onItemClick(AdapterView<?> parent,
View view, int position, long id){
//cast the
TextView wordView = (TextView)
//retrive the chosen word
String wordChosen= (String) wordView.
//output for debugging
Log.v(LOG_TAG, "chosen:" +wordChosen);
}});
super.onActivityResult(requestCode, resultCode, data);
}
}
In this app the user presses a button and gets displayed with the Google Voice Input screen where you can click a button (it actually goes automatically) and you can speak, it will stop and it will display it. I don't want that window to pop up at all though. Instead just let the user click the button and be able to speak and let the app stop and display the text automatically (it already does that).
PLEASE! I understand that there are already answers on the form showing how to do this, in fact a user name JEEZ posted some code right here.
I don't know if I understood where to put this in my project file. I AM A NOOB! If anyone could help clarify this I would GREATLY appreciate your help.
Here is my code:
package com.example.speechrecognizertest;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.TextView;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
private static final int VR_REQUEST = 999;
public static final String TAG = null;
private ListView wordList;
private final String LOG_TAG = "SpeechRepeatActivity";
private SpeechRecognizer mSpeechRecognizer;
private Intent mSpeechRecognizerIntent;
private boolean mIslistening;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speechBtn = (Button) findViewById(R.id.speech_btn);
wordList = (ListView) findViewById(R.id.word_list);
PackageManager packManager = getPackageManager();
List<ResolveInfo> intActivities = packManager.queryIntentActivities(
new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
if (!mIslistening)
{
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
} else {
speechBtn.setEnabled(false);
Toast.makeText(this, "Oops - Speech Recognition Not Supported!",
Toast.LENGTH_LONG).show();
}
}
#Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
protected class SpeechRecognitionListener implements RecognitionListener
{
#Override
public void onBeginningOfSpeech()
{
//Log.d(TAG, "onBeginingOfSpeech");
}
#Override
public void onBufferReceived(byte[] buffer)
{
}
#Override
public void onEndOfSpeech()
{
//Log.d(TAG, "onEndOfSpeech");
}
#Override
public void onError(int error)
{
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
//Log.d(TAG, "error = " + error);
}
#Override
public void onEvent(int eventType, Bundle params)
{
}
#Override
public void onPartialResults(Bundle partialResults)
{
}
#Override
public void onReadyForSpeech(Bundle params)
{
Log.d(TAG, "OnReadyForSpeech"); //$NON-NLS-1$
}
#Override
public void onResults(Bundle results)
{
//Log.d(TAG, "onResults"); //$NON-NLS-1$
ArrayList<String> suggestedWords = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
// matches are the return values of speech recognition engine
// Use these values for whatever you wish to do
wordList.setAdapter(new ArrayAdapter<String>(this, R.layout.word, suggestedWords));
}
#Override
public void onRmsChanged(float rmsdB)
{
}
}
AndroidManifest.xml
Add the following permission:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
class members
private SpeechRecognizer mSpeechRecognizer;
private Intent mSpeechRecognizerIntent;
private boolean mIslistening;
In onCreate
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
.........
.........
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
SpeechRecognitionListener listener = new SpeechRecognitionListener();
mSpeechRecognizer.setRecognitionListener(listener);
}
in your button listener just use this code
if (!mIsListening)
{
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
}
In onDestroy
if (mSpeechRecognizer != null)
{
mSpeechRecognizer.destroy();
}
Inside your activity create the inner class
protected class SpeechRecognitionListener implements RecognitionListener
{
#Override
public void onBeginningOfSpeech()
{
//Log.d(TAG, "onBeginingOfSpeech");
}
#Override
public void onBufferReceived(byte[] buffer)
{
}
#Override
public void onEndOfSpeech()
{
//Log.d(TAG, "onEndOfSpeech");
}
#Override
public void onError(int error)
{
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
//Log.d(TAG, "error = " + error);
}
#Override
public void onEvent(int eventType, Bundle params)
{
}
#Override
public void onPartialResults(Bundle partialResults)
{
}
#Override
public void onReadyForSpeech(Bundle params)
{
Log.d(TAG, "onReadyForSpeech"); //$NON-NLS-1$
}
#Override
public void onResults(Bundle results)
{
//Log.d(TAG, "onResults"); //$NON-NLS-1$
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
// matches are the return values of speech recognition engine
// Use these values for whatever you wish to do
}
#Override
public void onRmsChanged(float rmsdB)
{
}
}
EDIT 2015-02-07: Incorporated code from the answers to this question by ZakiMak and Born To Win into the code in this answer to make this one more complete.
Don't Forget to add permission of following:-
<uses-permission android:name="android.permission.RECORD_AUDIO" />
It's been a long time since the post. Still for those who are looking, the above code provided by Hoan is almost complete, but there is an important line missing. Both in question and answer and I am not sure how it could work without that.
You need to create the SpeechRecognitionListener and set it as a listener for the SpeechRecognizer. Also it has to be done before we make a call to startListening() method of the SpeechRecognizer.
SpeechRecognitionListener listener = new SpeechRecognitionListener();
mSpeechRecognizer.setRecognitionListener(listener);
Then you also need to remove the listener from the onError event.
I ran into that issue as well. It seems like having startActivityForResult(...) will enable the pop-up mic, then you can handle the response in onActivityResult(). However, simply adding that startActivityForResult messed up my startListening(mSpeechRecognizerIntent), so you may need to do more adjustment.
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
startActivityForResult(recognizerIntent, 100);
// call back
onActivityResult(int requestCode, int resultCode, Intent data){...}

ProgressDialog shows up after thread is done

I have the following three classes:
When I try to show a progressDialog when the WorkingThread is running, the ProgressDialog only shows up after the WorkingThread is done. What am I doing wrong?
I am not interested in using an AsyncTask!
-StartActivity:
public class StartActivity extends Activity implements OnClickListener
{
public ProgressDialog pgd;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgv = (ImageView)findViewById(R.id.imageView1);
tv = (TextView)findViewById(R.id.textview);
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(this);
}
public void onClick(View v)
{
pgd = ProgressDialog.show(StartActivity.this, "", "Loading picture"); // Start ProgressDialog before starting activity
Intent ActivityIntent = new Intent(this, FirstActivity.class);
startActivityForResult(ActivityIntent, 0);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0 && resultCode == RESULT_OK)
{
pgd.dismiss(); //Stop ProgressDialog when FirstActivity is "done"
}
}
}
-
-FirstActivity:
public class FirstActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
WorkingThread wt = new WorkingThread();
wt.start();
try
{
wt.join();
Intent ActivityIntent = getIntent();
setResult(RESULT_OK, ActivityIntent);
finish();
}
catch (Exception e)
{
}
}
}
-WorkingThread:
public class WorkingThread extends Thread
{
#Override
public void run()
{
super.run();
try
{
Thread.sleep(5000);
}
catch (Exception e)
{
}
}
}
The problem is ProgressDialog always need current Activity context for display.But in your case ProgressDialog is little unfortunate
The reason is as soon as you fire ProgressDialog the next couple of lines take out Context from Current activity and starts Next Activity i.e FirstActivity.So your progressDialog gets no chance to present itself on the Screen.
Use an AsyncTask. Here's an example:
package com.example.test;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
ProgressDialog activityProgressDialog;
private Context context;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
new TestAsyncTask().execute();
}
});
}
private class TestAsyncTask extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
//Called before doInBackground.
//Initialize your progressDialog here.
activityProgressDialog = ProgressDialog.show(context,
"Test",
"Doing heavy work on background...", false,
false);
}
#Override
protected Void doInBackground(Void... v) {
//Do your work here
//Important!!! Update any UI element on preExcecute and
//onPostExcecute not in this method or else you will get an
//exception.
//The below code just make the thread inactive for 5 seconds.
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
Thread.currentThread().notify();
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(Void v) {
//Dismiss the progessDialog here.
activityProgressDialog.dismiss();
}
}
}
I just show your edit that you don't want to use an AsyncTask. I will not delete this answer (unless you want me to) since it is another way of doing what you wanted to do.
try
{
wt.join();
Intent ActivityIntent = getIntent();
setResult(RESULT_OK, ActivityIntent);
finish();
}
here is your problem. The UI thread is waiting the Working Thread to finish becaouse of the join().

Categories