My activity looses the track of its notification when the application is removed from the recent apps My notification code :
builder = new NotificationCompat.Builder(this).setContentTitle("Started").setSmallIcon(R.drawable.ic_launcher);
targetIntent = new Intent(getApplicationContext(), MainActivity.class);
targetIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
contentIntent = PendingIntent.getActivity(this, 0, targetIntent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(contentIntent);
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1234, builder.build());
I have to restart the app after that and the notification doesn't open the activity any more.
Any leads on this ???