onNewIntent(Intent intent)
我在函数内部显示警报时遇到问题。Pending Intent extra 被正确检索,并且它的值按预期记录,但不显示警报。
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Bundle extras = getIntent().getExtras();
if(extras !=null) {
String value = extras.getString("message");
Log.v("alert", value); // <--- this line works fine.
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("title");
alertDialog.setMessage(value);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
}
}