简体   繁体   English

如何在Android上检测屏幕固定的锁定和解锁

[英]How to detect lock and unlock of screen pinning on android

I am working on an android app that should be used by students in some kind of practical test. 我正在开发一个Android应用程序,学生应该在某种实践测试中使用它。 I am using the screen pinning that was introduced in Lollipop ( startLockTask() ), so when my app is launched the user needs to allow the locking. 我使用的是Lollipop( startLockTask() )中引入的屏幕固定,因此启动我的应用程序时,用户需要允许锁定。

I couldn't find a way to know when the user click ok for the locking and when he unlock the pinning? 我无法找到一种方法来知道用户何时单击“确定”进行锁定以及何时解除锁定? (The user can cancel the lock by holding both the Back and Recent buttons). (用户可以通过同时按住“后退”和“最近”按钮来取消锁定)。 I am not looking for a way to know if the user currently in lock screen (getLockTaskModeState ()), i want to know if i have a way to handle the events of locking or unlocking. 我不是在寻找一种方法来了解用户当前是否处于锁定屏幕 (getLockTaskModeState()),我想知道是否有一种方法来处理锁定或解锁事件

I want that in the begining of the test i will be able to send information to my server if the users 'logged in' properly (by allowing the lock), and as well if the user unlock the device before the end of the test. 我希望在测试开始时,如果用户正确地“登录”(通过允许锁定),并且用户在测试结束之前解锁了设备,我将能够向服务器发送信息。

EDIT 编辑

Hey, people! 嘿,人! Please explain yourselves after downvoting! 投票后请自行解释! If I wasn't exaplaining myself - i will try again if you will let me know. 如果我不自责-如果您让我知道,我会再试一次。 I read a lot of questions and answers about general lock screen, but not the one of app pinning, I also read about check the status of the current task- if it is locked or not, but i didn't find answer to what i am asking - is there a way to handle the event of unlocking the 'screen pinning' of a specific app. 我读了很多有关常规锁定屏幕的问题和答案,但不是应用程序固定的问题和答案,我还阅读了有关检查当前任务状态的信息-是否已锁定,但我没有找到答案询问-是否有办法处理解锁特定应用程序的“屏幕固定”事件。 So please, explain your downvotes! 因此,请解释一下你的反对意见!

Device Admin Recevier class give you the event of pinning and unpinning... However the example use the class when the installed app is provisioned for device owner.. Not sure if you could use it. Device Admin Recevier类为您提供了固定和取消固定的事件...但是,当为设备所有者预配已安装的应用程序时,该示例将使用该类。不确定是否可以使用它。 You may refer to this too : How to be notified when screen pinning is turned off in Android 5.0 Lollipop? 您也可以参考此内容: 在Android 5.0 Lollipop中关闭屏幕固定时如何通知?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在android上检测和控制手机锁定/解锁? - How to detect and control the phone lock/unlock on android? 如何使用 KivyMD 检测 android 中的手机锁定/解锁? - How to detect phone lock/unlock in android with KivyMD? Android:如何通过锁定屏幕显示对话框或活动[未解锁屏幕] - Android : How to show dialog or activity over lock screen[ not unlock the screen] 如何以编程方式锁定/解锁屏幕? - How to Lock/Unlock screen programmatically? 在Android上检测解锁屏幕类型 - Detect unlock screen type on Android Cordova / Ionic2 | 如何锁定和解锁Android和iOS屏幕? - Cordova/Ionic2 | How to lock and unlock Screen of Android and iOS? 如何在Android应用程序中开发“屏幕锁定/解锁”功能? - How to develop an Screen-Lock/Unlock functionality in my application in Android? 如何在Android中使用模式/密码模式锁定/解锁屏幕? - How to lock/unlock the screen with Pattern/Password mode in Android? 如何在Android模拟器上获取锁定解锁屏幕? - How can i get lock unlock screen on emulator in android? 在 Android 中锁定/解锁屏幕时如何启用/禁用辅助功能服务 - How Enable/Disable Accessibility Service When Lock/Unlock Screen in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM