Android 锁屏生命周期问题

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

 

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值