kotlin - 有没有办法提示用户输入密码停止锁定任务模式?
问题描述
我想使用锁定任务模式来锁定设备以使用单个应用程序,但能够让用户输入密码以退出锁定任务模式。我更喜欢使用工具栏中的项目来停止锁定任务模式。这些设备本质上是服务提供商用来访问信息的信息亭。它们将分布在全国各地,无法访问互联网,因此我需要一种方法让远程用户将它们从锁定任务模式中解救出来以进行故障排除。任何想法将不胜感激,谢谢。
解决方案
我想到了。我创建了一个带有密码输入的警报对话框,使其脱离锁定任务模式。
private fun showAlertWithTwoButton() {
val alertDialog = AlertDialog.Builder(this).create()
alertDialog.setTitle(Constant.ALERTTITLE)
val input = EditText(this)
input.hint = "Enter Password"
input.transformationMethod = PasswordTransformationMethod.getInstance()
input.inputType = InputType.TYPE_CLASS_TEXT or
`enter code here`InputType.TYPE_TEXT_VARIATION_PASSWORD
alertDialog.setView(input)
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, Constant.ACCEPT) {
dialogInterface, i ->
val password = input.text.toString()
if (password == "your password") {
// Do something here when clicking accept button
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, Constant.REJECT) {
dialogInterface, i ->
// Do something here when clicking reject button
}
alertDialog.setOnCancelListener(DialogInterface.OnCancelListener {
// Do something here when clicking outside of alertdialog
})
alertDialog.show()
}
推荐阅读
- python - 类中的包罗万象的方法,将所有未知函数传递给类中的实例
- javascript - 角度守卫我如何从 auth.service.ts 获得价值(用户登录与否)
- vue.js - 如果 v-model 为空,VueJS 将第一个单选按钮设置为选中
- sas - 如何解释对数指数非线性回归?
- java - @Focus 多次调用 - Eclipse e4
- python - (python-telegram-bot)AttributeError:“更新”对象没有属性“机器人”
- intellij-idea - 无法运行程序“java”(在目录“/home/user/corda/build/nodes/Notary”中):错误=2,没有这样的文件或目录
- javascript - 被点击
- 里面作为孩子的项目
- 使用 React 的父级
- 里面作为孩子的项目
- ruby-on-rails - .idea/workspace.xml 到底是什么?
- sql - 是否有任何解决方案可以将此 SAS 代码写入“proc sql”进程?