savepopulation savepopulation - 8 days ago 4
Android Question

Android Launch Mode Single Task

In my app i have a dashboard activity and it's launch mode is "SingleTask" Are there any chances that my app gets in onNewIntent without onCreate?

For example if user navigates to another activity from Dashboard and after Dashboard is destroyed, what happens if user navigates to dashboard again?

Will onCreate work or just will go on from onNewIntent?

Thanks.

Answer

According to the Android API docs, onNewIntent will only get 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).

Since you are using SingleTask, onNewIntent should not get called.

See: https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)