This is WORK AROUND - not an IMO solution.
Problem
Remember that the problem was onCreate () and onNewIntent (), which gave the activity the same intention no matter what (nothing was sticky). The worst offender was onCreate (), because the Bundle savedInstanceState was always null.
Work around
I created a serializable (allows sFOO call) class that contains intentions and a timestamp from additional intentions. During onCreate (), I load this serialized class (sFOO). During onStart (), I compare sFOO with the processed intent. If everything is new, I know that I need to process the intent and update sFoo, and then save. If not, I ignore the intention.
Do you need a code?
In onStart ()
Intent activityIntent = this.getIntent(); if (activityIntent != null) { if (activityIntent.getAction() != null) { boolean newIntent = false; //Is the intent action being processes same as previous? if (activityIntent.getAction().compareTo(this.mLastProcessedIntent.mLastIntentProcessedAction) == 0) { if (activityIntent.getExtras() != null) { //Is the intent time stamp being processed same as previous? if (activityIntent.getExtras().getLong(TIME_STAMP_KEY) != this.mLastProcessedIntent.mLastIntentProcessedTimestamp) { newIntent = true; } } } else { Log.d(TAG,"Last processed intent action does not equal new one."); newIntent = true; } if (newIntent) { updateAndSaveProcessedIntent(); /*YOUR CODE HERE TO HANDLE INTENT*/ } } }
source share