zoukankan      html  css  js  c++  java
  • 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。

  • 相关阅读:
    流程图
    如何撰写简历
    产品经理-visio
    关于 EF 对象的创建问题
    LINQ To EF
    IQueryable 与 IEnumberable 接口的区别
    UWP自动填充控件AutoSuggestBox小优化
    xamarin UWP证书问题汇总
    xamarin UWP中MessageDialog与ContentDialog的区别
    xamarin UWP自定义圆角按钮
  • 原文地址:https://www.cnblogs.com/ywtk/p/4140545.html
Copyright © 2011-2022 走看看