Activity.getIntent返回创建Activity的Intent。
在Activity从onPause变为onResume的情况下,有没有办法让Intent恢复Activity?
答案 0 :(得分:1)
解决方案是覆盖在onResume之前调用的Activity.onNewIntent。
答案 1 :(得分:0)
我发现如何添加此代码:
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
现在这应该是这样的:
notification = new Notification(R.drawable.icon,
"Notify", System.currentTimeMillis());
notification.setLatestEventInfo(this, "App name",
"App message", PendingIntent.getActivity(this,
0, new Intent(this, Main.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP),
PendingIntent.FLAG_CANCEL_CURRENT));
notification.flags |= Notification.FLAG_ONGOING_EVENT;