如何判断用户是从服务中锁屏 [英] How to tell if user is on lock screen from service

查看:123
本文介绍了如何判断用户是从服务中锁屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在后台运行简单的服务,我只是想知道,当用户在锁屏界面上还是不行,这样,我知道什么时候开始的过程。

I have simple service that running in the background and I just want to know when the user is on the lock screen or not, that way I know when to start a process.

推荐答案

检查出的类似的问题在这里问。使用 KeyguardManager 来检查设备被锁定。

Check out a similar question asked here. Use KeyguardManager to check if the device is locked.

KeyguardManager kgMgr = 
    (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
boolean showing = kgMgr.inKeyguardRestrictedInputMode();

这篇关于如何判断用户是从服务中锁屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆