码迷,mamicode.com
首页 > 移动开发 > 详细

Android 锁屏生命周期问题

时间:2014-12-03 18:58:59      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:android   style   io   ar   sp   strong   on   art   问题   

今天在做视频播放时碰到了一个问题:当用户按下电源键锁屏后(屏幕黑了)视频播放停止了。但是当按下解锁键后(屏幕亮,但是未解锁)的时候视频开始自动播放了。

 

我的Activity在manifest.xml 配置如下

android:configChanges="locale|orientation|keyboardHidden"

android:screenOrientation="landscape"


解决办法:

需要在android:configChanges="locale|orientation|keyboardHidden" 中添加一个screenSize 

android:configChanges="locale|orientation|keyboardHidden|screenSize "

 

谷歌官方说明:

The physical screen size has changed. This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display. A change to this configuration corresponds to a change in the smallestWidth configuration. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

 

主要是说,当你的程序目标API小于等于12时,切换显示就会重启你的Activity。

 

Android 锁屏生命周期问题

标签:android   style   io   ar   sp   strong   on   art   问题   

原文地址:http://www.cnblogs.com/ywtk/p/4140545.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!