Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: raise AlertDialog from background thread

In my activity there's some stuff going on in a background thread, which gets started in Activity_1. The processing of the background thread takes a while and I want to notify the user when it's completed via an AlertDialog. However, the user might have changed to Activity_2 or Activity_3 in the meantime and I would like to pop up the AlertDialog always in the current Activity.

Any idea how to realize this?

like image 679
znq Avatar asked Nov 25 '09 10:11

znq


1 Answers

I ended up doing something like this in my background thread. It works, but not sure if it is a "good" solution.

Looper.prepare();
mActivity.showDialogAlertDefault();
Looper.loop();
Looper.myLooper().quit();
like image 173
znq Avatar answered Oct 26 '22 10:10

znq