I want to create an alertdialog outside of my application.
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();
However, the context
is not an activity and this class is extends BroadcastReceiver
.
When I push notification, an error occured,
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
I saw WhatsApp that can pop out the dialog outside the application in samsung galaxy tab.