如何知道电话是否锁定模式

问题描述:

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

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.