public void showNotification(Context context,String pnrNumber){
Intent intent=new Intent(context,HomeActivity.class);
intent.putExtra("PNR", pnrNumber);
//To Clear the Activity Stack
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(context, uniqueNumber,intent, Intent.FLAG_ACTIVITY_CLEAR_TASK);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("TravelKhana")
.setContentText("Get food in train for the PNR:" +pnrNumber);
mBuilder.setContentIntent(contentIntent);
mBuilder.setDefaults(Notification.DEFAULT_SOUND);
mBuilder.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(uniqueNumber, mBuilder.build());
uniqueNumber++;
}
and in oncreate of the HomeActivity i am getting this string extra
if(getIntent().hasExtra("PNR")){
mPnrSearch.setTag(getIntent().getStringExtra("PNR"));
onClick(mPnrSearch);
}
And then in onClick(mPnrSearch);
public void onClick(View v) {
switch (v.getId()) {
case R.id.pnrSearch:
if(NetworkChecker.isConnected(getApplicationContext())) {
easyTracker.send(MapBuilder.createEvent("Home Activity","click", "PNR", null).build());
}
Intent pnrIntent = new Intent(HomeActivity.this, PnrSearch.class);
//If the user came from notification
if(v.getTag() != null){
pnrIntent.putExtra("PNR", v.getTag().toString());
v.setTag(null);
getIntent().removeExtra("PNR");
}
startActivity(pnrIntent);
break;
}
I removed the extra and then I pressed the back button to destroy the app and reopened it by long pressing the home button in my phone and then after the extra is still there and onClick(mPnrSearch) is called again, but i have removed the extra why is it so?? and what do i need to do to resolve this out.