Hi I try show progress dialog when mymethod is running with code that below. When thread starts the progress dialog stop I dismiss it at the end of the method that called in thread. How can I solve this?
>mDialog = new ProgressDialog(DealActivity.this);
mDialog.setMessage("Loading...");
mDialog.setCancelable(false);
mDialog.show();
mDialog.setProgress(0);
new Thread() {
public void run() {
mymethod();
}
}.start();
Use
AsyncTaskinstead of thread. Show yourProgressDialoginonPreExecute()method call yourmymethod()indoInBackGround()and dismiss you progressDialog inonPostExecute().Follow this tutorial for better explanation.
Android Threads, Handlers and AsyncTask
You’ll also find this tutorial related to your need.
Managing AsyncTask, progress dialog and screen orientation