问题描述
我制作了一个Kiosk模式的应用程序,该应用程序在安装后运行良好(基于Activity.startLockTask()).
I have made a Kiosk-mode app that works well after install (is based on Activity.startLockTask()).
重新启动设备(运行Android 8.1的Nexus 5X)后,我无法使用该应用程序,因为无法使键盘出现在屏幕上.
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.
我发出命令以在应用程序处于活动状态时(全屏显示并设置为设备启动器)重新启动,以测试重新启动后它是否仍处于Kiosk模式.结果是它仍处于Kiosk模式,但用户无法激活软键盘.
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. Result is that it remains in Kiosk mode, but the soft keyboard cannot be activated by the user.
有什么想法为什么会这样?
Any ideas why it behaves like this?
该应用程序在Android 8.1模拟器上运行良好,并且在Android 5.1和Android 6.0上运行良好
The app works well on the Android 8.1 emulator and also works well on Android 5.1 and Android 6.0
任何帮助将不胜感激!
推荐答案
我已经通过将以下代码行添加到onCreate()方法(在调用super.onCreate()之后)解决了该问题:
I have solved the problem by adding this line of code to the onCreate() method (just after super.onCreate() is called):
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);
在创建对话框窗口时(在调用Dialog.show()之前)应该添加相同的内容.
The same should be added when creating dialog windows (before Dialog.show() is called).
这篇关于Android 8.1(API 27)-重启后键盘未在Kiosk模式的应用程序中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!