简体   繁体   中英

State of activity calling startActivity(Intent)

Can someone help me. What method of activity life cycle is called when the activity start new activity by method startActivity(Intent) ? I thought, that it is onPause() , but it can not be. I have it override to close SQLite connection, but it not happen.

Thanks

Sorry, maybe I described my problem wrong. Activity A start another activity B. My question is what method of activity A is called after start activity B by method startActivity(Intent) .

it runs into onPause then onStop . I tested it...

Check http://developer.android.com/images/activity_lifecycle.png

The onCreate is called when an activity gets started.

Because you start a new activity, that was not started before the method that gets called is onCreate . From the android developers site:

onCreate is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically.

You could just override both methods to check whether one of them is called. Just put an log output to each. Once you find the right one and the connection isn't closed ... maybe your close call is wrong.

Log.d("DEBUG", "Here in method METHODNAME")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM