I am trying to create some notifications. If you click on a notification, it will link to another activity. After the following code, it creates two lines of notification. But when I click on the first line of the notification, it does not work.
for (int i = 0; i < missionName.size(); i++) { mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); final Notification notifyDetails = new Notification(R.drawable.icon, "Mission Completed, Click Me!", System.currentTimeMillis()); notifyDetails.defaults |= Notification.DEFAULT_SOUND; notifyDetails.defaults |= Notification.DEFAULT_VIBRATE; Context context = getApplicationContext(); CharSequence contentTitle = missionName.get(i) + " is completed"; CharSequence contentText = "Please click to view the mission"; Intent notifyIntent = new Intent(getApplicationContext(),MissionMap.class); notifyIntent.putExtra("missionName", missionName.get(i)); PendingIntent intent = PendingIntent.getActivity(ApplicationMenus.this, 0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK); notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent); mNotificationManager.notify(i, notifyDetails); }
So please help me find my mistake. Thank you very much.
source share