I want to open last started activity by tapping on the notification in status bar. Suppose I start an Activity A (main activity of my app), this activity sends a notificatio
Have you tried this:
final Intent intent = new Intent(context, YourActivity.class)
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
The above codes instruct Android to open the last activity, whether it's the main activity or a preference activity [that's currently in the foreground] that you used to create/launch the icon in the notification bar in the first place.
ACTION_MAIN
and CATEGORY_LAUNCHER
refer to
and
directives respectively in your AndroidManifest.xml
file.