Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How we can use onNewIntent() in any Activity?

Tags:

android

What is the real use of onNewIntent() in the activity life cycle and how do we use this method?

like image 890
neeraj t Avatar asked Dec 02 '11 13:12

neeraj t


People also ask

How do you use onNewIntent?

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.

When onNewIntent is called in android?

OnNewIntent() always get called for singleTop/Task activities except for the first time when activity is created. At that time onCreate is called providing to solution for few queries asked on this thread.

What is on new intent in android?

The new intent comes as part of onNewIntent(Intent) . The original Intent is still available via getIntent() . You put whatever code you need to into onNewIntent in order to update the UI with the new parameters; probably similar to what you're doing in onCreate .


1 Answers

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.

like image 108
Padma Kumar Avatar answered Sep 28 '22 15:09

Padma Kumar