简体   繁体   中英

my application restart when i pressed home button

I have my android application that is running. I press "home button" to return to the menu application than I press on the my app icon to resume it, but is called the method "onCreate()" of my FIRST activity instead the method "onResume()" of the LAST activity seen before press the "home button".

I have this problem only on physical device and not on android emulator. Is there some attribute to set on Manifest File?

Have you any ideas?

Make sure that you don't have enabled the developer option: destroy activities when leaving them. I happened to me that I enabled this option and I forgot about it, so every activity was restarting each time.

There should be a Bundle being sent to your onCreate method. That bundle contains information on how to resume your app.

I recommend you put Log.d("",""); messages into your onCreate() and onResume() methods to see when which one is being called. Show me some code and I can help further.

Please see these: Android example which uses onResume, onStart and onRestart http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

Probably your device is running out or memory. Override the onLowMemory() method, and put a log in it or something to see if it is getting called or not.

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