我要创建我的申请,alertdialog之外。
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(Config_ConstantVariable.latest);
builder.setMessage(title);
builder.setIcon(R.drawable.push_logo);
builder.setCancelable(false)
.setPositiveButton(Config_ConstantVariable.alertbtnyes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(context,
Main_ParticularNewsDetail.class);
Bundle bundle = new Bundle();
intent.putExtra("newsid", payload);
intent.putExtras(bundle);
context.startActivity(intent);
}
})
.setNegativeButton(Config_ConstantVariable.alertbtnno,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
然而, context
是不是一个活动,这个类是extends BroadcastReceiver
。
当我推送通知,有错误发生,
06-18 18:38:08.629: E/AndroidRuntime(2402): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
我看到了WhatsApp可弹出的三星Galaxy Tab的应用程序之外对话。