0
我在onNewIntent(Intent intent)
函数中显示警报时遇到问题。等待意图额外检索正确,它的值按预期记录,但不显示警报。无法在onNewIntent()中显示警报
@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();
}
}
尝试这种情况:AlertDialog alertDialog =新AlertDialog.Builder(YourActivity.this).create(); – SKK 2013-05-14 11:42:11
@Santhosh - 正确!请张贴这个答案,以便我可以接受它。 – Kristopher 2013-05-14 11:45:34
快乐编码:) – SKK 2013-05-14 11:48:36