这是我在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 中总是给出错误。
this.getIntent().hasExtra("notification")
this.getIntent().hasExtra("notifiedby")
putExtra() 不能与 PendingIntent 一起使用吗?