当我preSS电源键,屏幕将自动关闭(全黑),系统破坏我的活动,然后重新创建它:
When I press the power key, the screen turns off (completely dark), the system destroys my activity and then recreates it:
03-28 22:48:00.934: V/[BB](5809): [GameControl] onPause
03-28 22:48:01.444: V/[BB](5809): [GameControl] onDestroy
03-28 22:48:01.724: V/[BB](5809): [GameControl] onCreate
03-28 22:48:03.016: V/[BB](5809): [GameControl] onResume
03-28 22:48:03.016: V/[BB](5809): [GameControl] onPause
这是造成的,因为我的活动都有一个固定的方向(横向)与锁屏的画像。
This is caused because my activity has a fixed orientation (landscape) and the lock screen is portrait.
我通过设定一个固定的纵向测试这个理论,这件事情不会发生。我也查了getResources()getConfiguration()值:
I tested this theory by setting a fixed portrait orientation and the issue doesn't happen. I also checked the getResources().getConfiguration() values:
{ scale=1.0 imsi=724/31 loc=pt_BR touch=3 keys=2/1/1 nav=1/1 orien=2 layout=17 uiMode=17 seq=36}
{ scale=1.0 imsi=724/31 loc=pt_BR touch=3 keys=2/1/1 nav=1/1 orien=1 layout=17 uiMode=17 seq=37}
{ scale=1.0 imsi=724/31 loc=pt_BR touch=3 keys=2/1/1 nav=1/1 orien=2 layout=17 uiMode=17 seq=38}
如何才能避免这种情况? 我不希望我的活动破坏了锁屏!
How can avoid that? I don't want my activity destroyed by the lock screen!
解决的办法就是添加一个机器人:configChanges =定位| keyboardHidden |屏幕尺寸你的活动在AndroidManifest.xml中
The solution is to add a android:configChanges="orientation|keyboardHidden|screenSize" on your Activity in your AndroidManifest.xml.
上一篇:包括Maven依赖于日食和QUOT;运行方式 - > Android的申请表]建立日食、申请表、方式、依赖于
下一篇:URL共享到Facebook,Twitter和电子邮件中的Android?电子邮件、Facebook、URL、Twitter