I am using BroadCast Listener to listen to incoming phone stat then pushing a Notification like this:
CharSequence contentTitle = "Contact: " + number;
CharSequence contentText = "Call From: " + number;
Intent notificationIntent = new Intent(context, CallHandler.class);
notificationIntent.putExtra(KEYS.NUMBER, number);
notificationIntent.putExtra(KEYS.STATE, stat);
notificationIntent.putExtra(KEYS.NAME, name);
notificationIntent.putExtra(KEYS.DURATION, duration);
notificationIntent.putExtra(KEYS.START_TIME, startTime);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notif.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify((int) System.currentTimeMillis(), notif);
So when there are multiple calls, I expect to have multiple call notification and when I click each notification, I expect to start an activity with the attached parameters. However, I can see that the Activities that starts later, gets the Intent of the previous call.
Here is how I am looking into intent from the Activity
Bundle extras = getIntent().getExtras();
String number = extras.getString(KEYS.NUMBER);
// String state = extras.getString(KEYS.STATE);
long duration = extras.getLong(KEYS.DURATION);
Date start = getStartDate();
((TextView) findViewById(R.id.subject)).setText("");
((TextView) findViewById(R.id.start_time)).setText(tf.format(start));
((TextView) findViewById(R.id.end_time)).setText(tf
.format(getEndDate()));
((TextView) findViewById(R.id.caller_number)).setText(number);
((TextView) findViewById(R.id.notes)).setText(getNotesDefaultContent(
number, duration, start));
How can I keep the intents separately call independent activity?