Expanding at the suggestion of Dalmas, if you turned out to be like me, where you created a dialog in a separate class to control the async task, then one line might be all you need to add:
mProgressDialog.setOwnerActivity((Activity)mContext);
This allows the Office to manage the dialogue. Longer snippet for reference ...
public DownloadCatalog(Context c) { mContext = c; } public void startDownload() { mProgressDialog = new ProgressDialog(mContext); mProgressDialog.setOwnerActivity((Activity)mContext); mProgressDialog.setMessage("Downloading \n" + remoteDirectory); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(false); new DownloadFileAsync().execute(fileUrl); } class DownloadFileAsync extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); mProgressDialog.show(); }
source share