I have an AlertDialog in and it’s got a button, which, if selected, will initiate a file upload to a remote server like this:
builder.setMessage(text)
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
uploadFile();
}})
This works fine, the only problem is that uploadFile() can potentially take a long time (30 seconds to 2 minutes). I would like to replace the AlertDialog with a progress dialog (even an indeterminate one), but I can’t see how to launch one dialog from another?
Can anyone offer some advice for a how I could accomplish this.
Thanks,
Jarabek
You can use
AsyncTaskhere, keep yourProgressDialogon thePreExecute()and call the method in thedoingInBackground()and dismiss the ProgressDialog in thePostExecute().Then just call the
MyAsyncTaskusingnew MyAsyncTask().execute();