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

谁说胖子不能爱 提交于 2019-12-25 03:43:20

问题


I have made a Kiosk-mode app that works well after install (is based on 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.

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?

The app works well on the Android 8.1 emulator and also works well on Android 5.1 and Android 6.0

Any help will be much appreciated!


回答1:


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);

The same should be added when creating dialog windows (before Dialog.show() is called).




回答2:


This happens when you try to activate kiosk when keyguard is active. Before activating kiosk you need to check 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

Don't start lock task mode when the device is locked because the user might not be able to unlock the device



来源:https://stackoverflow.com/questions/53676042/android-8-1-api-27-keyboard-not-showing-in-kiosk-mode-app-after-reboot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!