Android: raise AlertDialog from background thread

android, background, dialog, multithreading

Solution

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();

Problem

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?

Original source