【发布时间】:2016-07-30 03:52:37
【问题描述】:
在我的主要活动中:
LoginUser.loginUser(username.getText().toString(),password.getText().toString(), getApplication());
所以在我的 LoginUser 类中, 我想启动一个这样的对话框:
new AlertDialog.Builder(context).set.....
但失败了, 得到这样的故障信息:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
我也想用like
Intent intent = new Intent(context, ABC.class)
context.startActivity(intent);
也失败了。并得到这样的故障信息:
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
我对所有这些都很困惑,有人可以帮助我吗?非常感谢!
【问题讨论】:
-
请添加完整代码您将如何显示 dailog 表示活动或服务或片段中的位置?
标签: android android-intent android-activity android-alertdialog android-context