Such a simple thing but I'm having a huge problem with it.
EDIT: I want my ProgressDialog to run while other classes are running - NOT be called within an asyncTask, as there are multiple asyncTasks being called.
My main activity (index) calls another class, aTask, which calls an AsyncTask to grab some data from Yelp. When aTask returns the data, index starts a new activity.
I want index to show a progress dialog while aTask is running. So I use the answer from here to put a progress dialog in index.
However, the progress bar is only shown after aTask finishes, which completely defeats the purpose.
Here is the code:
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ProgressDialog.show(IndexActivity.this, "Loading", "Wait while loading...");
ATask at = new ATask(preferencesMap, IndexActivity.this);
final ArrayList<Business> locations = at.getLocations();
Intent intent = new Intent(IndexActivity.this, BTask.class);
intent.putExtra("EXTRA_DIRECTIONS_STEPS", locations);
intent.putExtra("EXTRA_MAP_LOCATIONS", locations);
startActivity(intent);
}
});