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

 

我的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。

 

转载于:https://www.cnblogs.com/ywtk/p/4140545.html

更多相关文章

  1. android 屏幕宽高
  2. Android屏幕刷新——源码分析
  3. android获取控件宽高和屏幕宽高
  4. 将android/ios屏幕投射到windows/mac的良好参考
  5. Android屏幕校准
  6. 【Android】技术调研:用代码模拟屏幕点击、触摸事件
  7. [Android UI]android-lockpattern图案解锁的实现分享
  8. 在Android的 设置->显示 中增加控制屏幕旋转方向的选项

随机推荐

  1. Android中文API(125) ―― VideoView
  2. Android控件-多选按钮、单选按钮
  3. Android中使用jdbc连接Sqllite
  4. android延迟执行任务(刷新按钮旋转)
  5. Android:Eclipse+ADT+Android SDK 搭建安
  6. “刨根问底”之Android(安卓)消息机制
  7. Android ActionBarSherlock的使用
  8. 打开电话Android系统调用
  9. Android兼容性测试
  10. [置顶] Android如何使用Https