I have created one AsyncTask class for fetching data from background (Accessing database).
In onPreExecute() method, I create one progress dialog
try {
progressDialog = ProgressDialog.show(context, "",
"Please wait...", true);
progressDialog.setIndeterminate(true);
} catch (final Throwable th) {
// TODO
}
And in onpostExecute()
protected void onPostExecute(Boolean result) {
pinPoint();
progressDialog.dismiss();
}
My updated class,
@Override
protected Boolean doInBackground(Void... params) {
clust = getPinPointClusters();
runOnUiThread(new Runnable() {
public void run() {
plotClusters(clust);
}
});
return true;
}
@Override
protected void onPostExecute(Boolean result) {
progressDialog.dismiss();
}
Here pinpoint() method will get some data from server and pin the points in map.
But The progressBar in ProgressDialog is not animating…
Please provide me the best way…
Thanks
I would suggest you to put the pinPoint() method in the
doInBackground methodand the lines of the method pinPoint() which are affecting the UI can be kept under this method::Example : When any line attempts to change the UI in the doInBackground , do this way:
Now,you have to just dismiss the
ProgressDialogfrom the onPostExecute() method.