search

Home  >  Q&A  >  body text

Android 锁屏监听问题?

我在某个Activity里想判断onPause的原因,到底是锁屏?按了home?覆盖了新activity?按了返回键?还是从通知栏点击图标向另一个app离开了?

我的目的是当锁屏的时候做一个响应,其他情况统一做一个响应。
这个怎么实现啊?
好像都会调用onPause和onStop...

天蓬老师天蓬老师2772 days ago353

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:45:29

    Try to judge by listening to the screen off and on screen unlock broadcast http://blog.csdn.net/mengweiq...

    reply
    0
  • 黄舟

    黄舟2017-04-17 17:45:29

    You should monitor the physical buttons to identify the home button, the return button or the lock screen button to distinguish the situation of leaving the Activity
    The method of monitoring buttons can refer to the monitoring of android physical buttons

    reply
    0
  • Cancelreply