Java 在Android中,当从锁定屏幕单击通知操作时,如何以编程方式解锁屏幕?
当屏幕被锁定并且用户从锁定屏幕选择对通知操作的肯定响应时,如何添加代码以提示屏幕解锁?以下是我已添加到通知生成器的当前积极通知操作的代码,选择此操作后,我已在类中添加了一个意图,该意图扩展了IntentService以导航到应用程序中的活动:Java 在Android中,当从锁定屏幕单击通知操作时,如何以编程方式解锁屏幕?,java,android,Java,Android,当屏幕被锁定并且用户从锁定屏幕选择对通知操作的肯定响应时,如何添加代码以提示屏幕解锁?以下是我已添加到通知生成器的当前积极通知操作的代码,选择此操作后,我已在类中添加了一个意图,该意图扩展了IntentService以导航到应用程序中的活动: private static Action yesLetsGo(Context context) { Intent intent = new Intent(context, NotificationIntentService.class)
private static Action yesLetsGo(Context context) {
Intent intent = new Intent(context, NotificationIntentService.class);
intent.setAction(NotificationTasks.ACTION_YES_LETS_GO_NOTIFICATION);
PendingIntent yesLetsGo = PendingIntent.getService(
context,
ACTION_YES_LETS_GO_PENDING_INTENT_ID,
intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Action yesLetsGoAction = new Action
(R.drawable.ic_launcher_background,
"Yes Lets Go",
yesLetsGo);
Log.i("Notification Utils","yesLetsGo method called");
return yesLetsGoAction;
}
要在Android中启用或禁用锁屏,我们需要获得KeyguardManager的实例 以及禁用锁的使用
lock.disableKeyguard();
当然我们需要舱单上的许可
android.permission.DISABLE_KEYGUARD嗨,这是很久以前的事了,但很高兴它对你有用。请你接受这个答案,让其他人知道它是有效的。只需点击答案左边箭头下方的勾号
lock.disableKeyguard();