I am trying to pop up dialog from run method it gives me exception that Looper.prepare not called, when I call the same method i dont get any exception but there is no pop up dialog shown on the console. As I have used handler in this way ,
handler = new Handler() {
public void handleMessage(Message msg) {
showDialog(DIALOG1_KEY);
// process incoming messages here
}
};
I am not getting any exception again but still no luck can any body tell me where I am doing things wrong.
It’s hard to tell from the code snippet you’ve provided, but I think you’re using the Handler incorrectly.
What you need to do is initialize a new
Handlerobject on them main thread, for example by defining it as a field variable.Then create a new
Runnablethat includes the instructions you want to execute on the GUI thread (but which will be called from your background thread’srunmethod).Then within your run method you need use the handler object to post your
runOnGUImethod on the GUI thread.