i’m looking for a way to show a Dialog no matter what activity is shown.
I think what I’m trying to achieve is better explained using some code :
public class MyApp extends Application {
public MyApplication() {
}
@Override
public void onCreate() {
super.onCreate();
boolean success = doSomeWebServiceCall();
if (!success)
showAlertDialog(); // fails with error
}
}
The error I am getting is :
ERROR/AndroidRuntime(375): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
at android.view.ViewRoot.setView(ViewRoot.java:460)
Only an
Activitycan display aDialog. Consider using a dialog-themedActivityinstead, which can be launched from yourApplicationobject viastartActivity().