0

I was wondering what is the difference between running android application from home screen (app icon) vs running it from task manager. Whenever I run it from the home screen I can see a splash screen for a short period of time, but after that I'm forwarded to the latest application state. The only difference when running it from task manager is that I don't see the splash screen. Is there any reasonable explanation behind that behavior? Sometimes when running application from home screen (app icon) it hangs on splash screen forever and I am unable to debug it in any way...

Kamil N.
  • 91
  • 11
  • By `it hangs on splash screen forever and I am unable to debug it in any way`, it is normal, you just need to wait for Android to load your app. Xamarin.Android need mono to run its c# codes, the mono need JVM to load, so it need more time on splash screen than Native Android. – Robbit Feb 05 '18 at 09:23
  • Yes, you are right, but returning to the app sometimes takes much more time than running it for the first time. And that is what bugs me. – Kamil N. Feb 05 '18 at 14:07

2 Answers2

1

You need to know the lifecycle of Activity, like @FabriBertani has said. You can see the lifecyle of Activity by its lifecycle methods:

OnCreate -> OnStart -> OnResume -> OnPause -> OnStop -> OnDestroy.

This is Activity's normal lifecycle.


There are several categories about from home screen and from task manager

Running android application from home screen

  • If the app has been running in your device recently, that means Android Warm Start.

  • If the app hasn't been running in your device recently, that means Android Cold Start, so we usually use splash screen to deal with it.

Running android application from task manager

  • Your app is background and it has been killed by system, because of lack of resources.
  • Your app is background and it hasn't been killed by system.

Is there any reasonable explanation behind that behavior?

Yes. From your situation, it should be Android Cold Start and not been killed.

  • Android Cold Start will create an App from zero, so it will call:OnCreate -> OnStart -> OnResume, before call Activity's OnCreate, it need create the environment which an App need, so you will see the splash screen. If we don't set our custom splash screen, you will see a white or black screen before you see the latest application state.
  • Running app from task manager(not been killed) did create an App from zero. If you press Home Button instead of Back Button, your app will be in recent apps, it will call:OnPause -> OnStop, and when you run app from task manager, it will call:OnRestart -> OnStart -> OnResume, so you can't see the splash screen.
Community
  • 1
  • 1
Robbit
  • 4,300
  • 1
  • 13
  • 29
0

It is because the app restarts rather then resumes when you start it from home screen. You can find the explanation this behavior here App restarts rather than resumes

  • But It doesn't look like it restarts because it goes back to place where I left it. Or maybe Im just not understanding "restart" the way I should. For me restarting is when I start everything from beginning. So when I move from screen A to B then restarting should point me to screen A, not B. Thanks for the link though, It explains a lot. – Kamil N. Feb 02 '18 at 13:52
  • Read this: [Android Activity Lifecycle](https://developer.android.com/guide/components/activities/activity-lifecycle.html), try to understand all the Android lifecycle states, there is the answer to your question ;-) – FabriBertani Feb 02 '18 at 14:37