i am create messenger with android, every message receive will show notification, when app receive some message from some one will call this method, content is message from friend, and title is name of friend, and every people have ID, and also i pass Friend ID to FriendID parameter.
public static void CreateNotify(Context context, String Content, String title, String FriendID) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(icon)
.setContentTitle(title)
.setContentText(Content)
.setLights(Color.BLUE, 1000, 500)
.setAutoCancel(true);
Intent resultIntent = new Intent(context, Messenger.class);
resultIntent.putExtra("ID", FriendID);
int mNotificationId = FriendID.hashCode();
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, mNotificationId, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT|Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotifyMgr = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(mNotificationId, mBuilder.build());
}
every things is ok, but if my friend (A) send me message i see notification and i click it will show me Messenger activity, in this state my friend (B) send me message i click on notification i will see messanger of my (B) friend... now when my friend (A) send me new text message, in notification will show me notification from my (A) and when i click on it Messenger activity will create new and will show me... i want instead of create new instance, bring to front last instance of messenger (A)