Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App launch in android

We can launch the app in two ways, 1 is form the app, clicking on device back button till we reach the android home screen and launching the app or 2nd is from the app we can click the device home button and then we can launch.

How can we differentiate these to launches? In 2nd type launch onrestart will be called, onrestart will be called in some other cases also.

I want to do something in the 2nd type of launch.

Can any one tel me how to do this...

Thanks in advance.

like image 952
Padma Avatar asked Apr 29 '26 23:04

Padma


1 Answers

When it comes to what happens when the activity is started, you may want to look at the following link in the developer site.

http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

You may want to code based on the lifecycle of the activity rather than if the application was pushed to the background by the home key vs. by the back key. There could be different reasons the application was pushed to the background or closed. This is the expected way to handle application events.

like image 60
dlongest Avatar answered May 01 '26 13:05

dlongest