What is the real use of onNewIntent()
in the activity life cycle and how do we use this method?
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.
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.
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 .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With