如何知道电话是否锁定模式 [英] How to know whether the phone is locked mode

查看:86
本文介绍了如何知道电话是否锁定模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好有没有让我知道手机是否处于锁定状态?办法

HI guys is there a way for me to know whether the phone is in lock state?

推荐答案

有您的应用程序听我们对 ACTION_SCREEN_OFF 播出。点击此处了解详情

Have your app listen our for the ACTION_SCREEN_OFF broadcast. More information here.

public class ScreenReceiver extends BroadcastReceiver {     

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
                //screen locked                
            } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
                //screen unlocked   
            }
        }

}

您可能还希望通过为的 ACTION_USER_ preSENT 播出。

You might also want to receive information of when the user gets past the keyguard by registering for the ACTION_USER_PRESENT broadcast.

这篇关于如何知道电话是否锁定模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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