I have a problem with my progress dialog from AsyncTask. Here's the scenario. I have an app which has an alert dialog, then checks something from db. If result is true then will call an AsyncTask which displays a progress dialog. Progress dialog is displaying behind Alert dialog. How can I display progress dialog in front of alert dialog?
AsyncTask:
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(ReadBibleActivity.this);
pDialog.setMessage(getResources().getString(R.string.translating_bible_version));
pDialog.setIndeterminate(true);
pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pDialog.setCancelable(false);
pDialog.show();
}
Alert Dialog:
private void displayDialog() {
customDialog = new Dialog(this);
customDialog.setTitle(getResources().getString(R.string.share));
customDialog.setContentView(R.layout.dialog);
etTitle = (EditText) customDialog.findViewById(R.id.etTitle);
etDescription = (EditText) customDialog.findViewById(R.id.etDescription);
if(caller == 1) {
String userVersion = dbHelper.getUserVersion(userId);
if((userVersion != null && !userVersion.isEmpty())
&& !userVersion.equalsIgnoreCase("TLC")) {
if(ConnectionDetector.hasNetworkConnection(this)) {
scrapeTask = new ScrapeAsyncTask();
scrapeTask.execute();
} else {
Toast.makeText(this,
getResources().getString(R.string.no_internet_connection),
Toast.LENGTH_SHORT).show();
}
} else {
etTitle.setKeyListener(null);
etTitle.setText(verse);
etDescription.setText("\"" + text + "\"");
etDescription.requestFocus();
}
} else {
etTitle.setHint(text);
etTitle.requestFocus();
etDescription.setHint(text);
}
customDialog.show();
}
Any ideas? Help will be greatly appreciated. Thanks!
try calling customDialog.show();
before scrapeTask = new ScrapeAsyncTask();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.