I want to show a progressBar while some instructions execute in background, but I don't want to lock the screen. This code is locking the screen:
private class ConvertDataInBackground extends AsyncTask<Params, Void, Boolean> {
private MyProgressDialog mProgressDialog;
@Override
public void onPreExecute() {
if(mProgressDialog == null)
mProgressDialog = MyProgressDialog.show(mActivity, null, null);
}
@Override
protected Boolean doInBackground(Params...params) {
boolean conversionResult = executeConversion(params[0].item1, params[0].item2, params[0].item3);
return conversionResult;
}
@Override
protected void onPostExecute(Boolean result) {
try {
if(mProgressDialog.isShowing())
mProgressDialog.dismiss();
if(result) {
Toast toast = Toast.makeText(mActivity, R.string.conversion_result, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Execution of instruction in background may take a while, and I want the user to be able to work with the interface. Do you know anyway that we can work with interface, while progressDialog is displaying at the top?