MimmoG
MimmoG

Reputation: 651

Android : activity destroy when display turn off

I have a problem with a code becuse when the display turn off the activity was destroy then it restart from onCreate....why ? when the display turn off the activity not must go to onPause??

Upvotes: 2

Views: 3662

Answers (2)

Steelight
Steelight

Reputation: 3357

Is your application in Landscape? if so, check this answer out: onDestroy gets called each time the screen goes on

Short answer: implement onConfigurationChanged() and change the AndroidManifest.xml file for this activity to: android:configChanges="keyboardHidden|orientation"

Upvotes: 2

Huang
Huang

Reputation: 4842

according to the life cycle of the Android activity, when an activity becomes background, onPause is called, however, from now on, the system can kill the activity by its will, ie. the system requires more memory.
what you met was normal.

Upvotes: 1

Related Questions