我正在寻找一种显示对话框的方式,无论显示何种活动。如何从应用程序实例中触发对话框?
我想什么,我想要实现更好的使用一些代码解释:
public class MyApp extends Application {
public MyApplication() {
}
@Override
public void onCreate() {
super.onCreate();
boolean success = doSomeWebServiceCall();
if (!success)
showAlertDialog(); // fails with error
}
}
我得到的错误是:
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)
谢谢,我会试一试! – David 2011-05-18 05:02:07
你给startActivity的背景是什么? – David 2011-05-18 17:57:35
@David:'Application'是一个'Context'。 – CommonsWare 2011-05-18 17:58:18