How we can use onNewIntent() in any Activity?
This is called for activities that set launchMode to "singleTop" in their package, or if a client used the FLAG_ACTIVITY_SINGLE_TOP flag when calling startActivity(Intent).
If you set to single top, the activity will not be launched if it is already running at the top of the history stack. It will not relaunch just show from stack.
Check this link onNewIntent()
In manifest.xml, in an activity tag set launchmode="singleTask"
Above answers are incomplete.
In case the activity 'a1' of Application 'A1' has launch mode "singleTask" or "singleTop" and is already alive (in task t1) but paused, and now another task (say Task t2) (usually another android app) sends an intent to activity a1 of application A1, then instead of creating another instance of activity in task t2, android resumes a1 from task t1, by issuing a callback to onNewIntent(intent) method in a1.
Tasks and back stack is an important concept, no blog explains better than android documentation itself.