I have a notification on my app. It works in foreground well. When i`m in a other activity and press home button after that i click notification. It opens given activity, but i need to display previous activity in a saved state.
Notification note = new Notification(R.drawable.service_state_0,
getResources().getText(R.string.serviceStarted),
System.currentTimeMillis());
Intent i = new Intent(this, StartingActivity_.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
note.setLatestEventInfo(this,
getResources().getText(R.string.app_name), getServiceStateDescription(CustomService.this), pi);
note.flags |= Notification.FLAG_NO_CLEAR;
note.flags |= Notification.FLAG_ONGOING_EVENT;
startForeground(ContextConstants.LAUNCHER_SERVICE_NOTE_ID, note);
It always shows StartingActivity, the question is that how to call resuming activity when notification is clicked. If the activity has not already been destroyed and i can just call that instance back(resume it) and therefore not needing to load it again and won't need to add another activity to my stack. Is it possible?
I find a solution like open recently activity in Notification:
you have to add
<uses-permission android:name="android.permission.GET_TASKS" />