Android 如何知道用户触摸图案屏幕?
我想知道,当用户尝试解锁模式屏幕时?如何获得锁定屏幕模式的触控事件?Android提供了几个API,让您可以帮助了解用户界面控件是否可聚焦,甚至请求对控件进行聚焦: 当其android:focusable属性设置为true时进行方向控制Android 如何知道用户触摸图案屏幕?,android,android-service,Android,Android Service,我想知道,当用户尝试解锁模式屏幕时?如何获得锁定屏幕模式的触控事件?Android提供了几个API,让您可以帮助了解用户界面控件是否可聚焦,甚至请求对控件进行聚焦: 当其android:focusable属性设置为true时进行方向控制 setFocusable() isFocusable() requestFocus() 作为Detect屏幕锁定的替代方案,我认为以下方法将起作用: @Override protected void onPause() { su
setFocusable()
isFocusable()
requestFocus()
作为Detect屏幕锁定的替代方案,我认为以下方法将起作用:
@Override
protected void onPause()
{
super.onPause();
// If the screen is off then the device has been locked
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
boolean isScreenOn = powerManager.isScreenOn();
if (!isScreenOn) {
// The screen has been locked
// do stuff...
}
}
编辑:
您还可以使用Intent
检查请简要说明您的问题。你在说什么模式?您想获取设备的锁定按钮事件吗?@GrIsHu是的。我想获取设备的锁定按钮事件。谢谢您的回复。我会尝试一下并通知您。