简体   繁体   English

Android 8.1(API 27)-重启后键盘未在Kiosk模式应用中显示

[英]Android 8.1 (API 27) - Keyboard not showing in Kiosk-mode app after reboot

I have made a Kiosk-mode app that works well after install (is based on Activity.startLockTask()). 我制作了一个Kiosk模式的应用程序,该应用程序在安装后运行良好(基于Activity.startLockTask())。

After re-booting the device (a Nexus 5X running Android 8.1), I cannot use the app because the keyboard cannot be made to appear on screen. 重新启动设备(运行Android 8.1的Nexus 5X)后,我无法使用该应用程序,因为无法使键盘出现在屏幕上。

I give the command to reboot while the app is active (in full screen and set as device launcher) in order to test if it remains in Kiosk mode after restart. 我发出命令以在应用程序处于活动状态时(全屏显示并设置为设备启动器)重新启动,以测试重新启动后它是否仍处于Kiosk模式。 Result is that it remains in Kiosk mode, but the soft keyboard cannot be activated by the user. 结果是它仍然保持在Kiosk模式,但是用户不能激活软键盘。

Any ideas why it behaves like this? 任何想法为什么它会这样?

The app works well on the Android 8.1 emulator and also works well on Android 5.1 and Android 6.0 该应用程序在Android 8.1模拟器上运行良好,在Android 5.1和Android 6.0上运行良好

Any help will be much appreciated! 任何帮助都感激不尽!

I have solved the problem by adding this line of code to the onCreate() method (just after super.onCreate() is called): 我已经通过将以下代码行添加到onCreate()方法中(已经在调用super.onCreate()之后)解决了该问题:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); getWindow()。addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

The same should be added when creating dialog windows (before Dialog.show() is called). 创建对话框窗口时(在调用Dialog.show()之前),应添加相同的内容。

This happens when you try to activate kiosk when keyguard is active. 当您在激活键盘锁时尝试激活信息亭时,会发生这种情况。 Before activating kiosk you need to check KeyguardManager.isKeyguardLocked(). 在激活信息亭之前,您需要检查KeyguardManager.isKeyguardLocked()。

There is a section about this problem (it's a bit indirect) at https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode#start_lock_task_mode https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode#start_lock_task_mode中有关于此问题的部分内容(有点间接)

Don't start lock task mode when the device is locked because the user might not be able to unlock the device 设备锁定时不要启动锁定任务模式,因为用户可能无法解锁设备

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM