Reputation: 5593
I have very strange behavior of Activity in my LibGDX game - when I play game and then press power button sending device to sleep mode. I've added logs to Activity's callback methods and that's what I see:
05-14 16:32:51.694: I/BP(32656): onPause()
05-14 16:32:51.704: I/BP(32656): onStop()
05-14 16:32:51.854: I/BPApplication(32656): BPApplication.onConfigurationChanged()
05-14 16:32:51.854: I/BP(32656): BP.onConfigurationChanged()
At this point all goes right way. Further some strange begins:
05-14 16:40:42.774: I/BP(32656): onRestart()
05-14 16:40:42.774: I/BP(32656): onStart()
05-14 16:40:43.064: I/BP(32656): onResume()
05-14 16:40:44.566: I/BP(32656): BP.onConfigurationChanged()
05-14 16:40:44.566: I/BPApplication(32656): BPApplication.onConfigurationChanged()
05-14 16:40:49.761: I/System.out(32656): screen resize w = 480, h=800 // libGDX callback
05-14 16:40:49.911: I/System.out(32656): GAME RESUMED... // libGDX callback
05-14 16:40:50.471: I/System.out(32656): screen resize w = 800, h=480 // libGDX callback
05-14 16:40:59.010: I/System.out(32656): GAME PAUSED // libGDX callback
05-14 16:41:00.711: I/BP(32656): onPause()
05-14 16:41:00.801: I/BP(32656): onStop()
05-14 16:41:00.851: I/BP(32656): onRestart()
.... this cycle repeats 5 - 10 times ....
So as you can see problem is that Activity.onRestart() and further callbacks calls when device is asleep. And this repeats 5-10 times during near one minute.
I don't understand why Activity restarts and what are performing this operation.
Im my game I have billing service v2 (implemented by other programmer) and setup AlarmManager for restore free game.
I am completely confused with this issue so any help will be appreciated.
UPDATE
It seems that deal in libGDX - I've build another project with same library version and it behaves exactly like my game.
Upvotes: 0
Views: 585
Reputation: 18712
In your AndroidManifest.xml, you should have something like-
<activity
android:name=".YourAppName"
android:configChanges="keyboardHidden|orientation|screenSize"/>
Upvotes: 1