这是我在 Service 类中的 showNotification 方法:
private void showNotification() {
Notification notification = new Notification(R.drawable.icon,
"New Notification", System.currentTimeMillis());
Intent i = new Intent(this, myActivity.class);
i.putExtra("notification", "MyNotif");
i.putExtra("notifiedby", "NotedBy");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0);
notification.setLatestEventInfo(this, "NotedBy", "MyNotif", contentIntent);
nm.notify(111, notification);
}
因此,在从状态栏中点击“通知”后,我会进入“myActivity”。
问题在于这些行在“myActivity”中始终返回false。
this.getIntent().hasExtra("notification")
this.getIntent().hasExtra("notifiedby")
putExtra()在PendingIntent中无法使用吗?