This has nothing to do with your issue, just nitpicking really, but unless
you need an Integer for your progress in the AsyncTask you shouldn't create
it.
Thus your AsyncTask should look more like
private class InitialiseServer extends AsyncTask<Void, Void, Boolean>
Also without some idea of what your code looks like you are going to have a
hard time getting help.
With that said, in its simplest form the AsyncTask:
*Note: If you do it this way make sure to handle activity changes like
orientation change otherwise your activity will throw an exception because
it will try to dismiss the dialog when the dialog doesn't exist any longer!*
private class InitServer extends AsyncTask(Void, Void, Boolean> {
ProgressDialog theProgress = new ProgressDialog(TheOuterClass.this);
@Override
protected void onPreExecute() {
super.onPreExecute();
this.theProgress.setMessage("Your progress message");
this.theProgress.show();
}
@Override
protected Boolean doInBackground(Void... voidArg) {
return false;
}
@Override
protected void onPostExecute(Boolean bool) {
super.onPostExecute(bool);
this.theProgress.dismiss();
if ( bool ) {
// Do something
} else {
// Do something else
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en