Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between launch app from "recent apps" and tapping app icon

Tags:

android

task

I'm working on large project, so there is some logic for saving application state, and then opening correct activity(fragment) when it comes from background. But anyway, I've found that if user navigates through my app and then minimize it - android opens it from background in different ways in following cases:

  1. User taps on app icon (behavior: user see home activity, doesn't matter where he was, when application was minimized)
  2. User select app from android "recent apps" (behavior: user see exactly what he saw, when the application was minimized)

So, what is the difference between launching application from background by this two ways? I always thought, that it is the same mechanism, but, obviously, I was wrong.

Thanks for any answers

like image 550
OFFmind Avatar asked Sep 12 '13 08:09

OFFmind


People also ask

What is recent app icon?

You'll be able to see your recent apps with a single tap. From the Home screen, tap the Recents icon to the left of the Home button. All of your active or opened apps will be listed. If you've customized your Navigation bar, Recents may be located on the right, unless you're using full screen gestures.

What happens when you launch an app in Android?

An Android process is started whenever it is required. Any time a user or some other system component requests a component (could be a service, an activity or an intent receiver) that belongs to your application be executed, the Android system spins off a new process for your app if it's not already running.


1 Answers

You should pay atention on the folowing docs Activity and Tasks. In short words: if user start app from recents you will receive onRestart before onStart (without onCreate it means that your app was just "suspended"). You able to save screen state using onSaveInstanceState(). But in general starting from icon and from recents - different application behaviors and you should provide proper code for this ways.

UPD As described below root cause of unexpected behaviour was additional lunchmode attribute.

like image 75
x90 Avatar answered Sep 18 '22 07:09

x90