I have a BroadcastReceiver that receives a push notification, I then start an activity and show a notification. (notice that the activity is not started when the user actions the notification)
My intention is to start the activity in "background mode" and then when the user responds to the notification bring the activity to the front.
All is working perfectly except that the activity briefly shows and then immediately hides. (flashing activity for a second).
Here is my code:
BroadcastReceiver...
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("BACKGROUND",true);
context.startActivity(intent);
MainActivity.....
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getBooleanExtra("BACKGROUND",false)) {
moveTaskToBack(true);
} else {
}