3
嗨,大家好我有办法知道手机是否处于锁定状态?如何知道手机是否处于锁定状态
嗨,大家好我有办法知道手机是否处于锁定状态?如何知道手机是否处于锁定状态
让您的应用听我们的ACTION_SCREEN_OFF
广播。更多信息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广播注册并获得过去的键盘锁的信息。
不工作的原因是http://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_ON只是看到那里是受保护的意图只能通过系统发送。如果您有其他选择,请发布 – 2011-11-25 08:02:19