检测uiMode或键盘更改android
我曾尝试构建一个测试应用程序,当配置发生变化时,它只传递一条toast消息。(好吧,这就是它应该做的,它不起作用)最终的目的是检测用户是否将平板电脑放入键盘托架或从键盘托架中取出。我的清单和主要活动如下。。我原以为当平板电脑的uiMode或外部键盘配置发生变化时,这段代码会让人敬酒。。但是当我把它装上/卸下时,什么也没发生。。请帮忙 我的舱单:检测uiMode或键盘更改android,android,android-ui,android-configchanges,Android,Android Ui,Android Configchanges,我曾尝试构建一个测试应用程序,当配置发生变化时,它只传递一条toast消息。(好吧,这就是它应该做的,它不起作用)最终的目的是检测用户是否将平板电脑放入键盘托架或从键盘托架中取出。我的清单和主要活动如下。。我原以为当平板电脑的uiMode或外部键盘配置发生变化时,这段代码会让人敬酒。。但是当我把它装上/卸下时,什么也没发生。。请帮忙 我的舱单: <?xml version="1.0" encoding="utf-8"?> 你的代码看起来不错,但是 如消息人士所说: /** * T
<?xml version="1.0" encoding="utf-8"?>
你的代码看起来不错,但是 如消息人士所说:
/**
* The kind of keyboard attached to the device.
* One of: {@link #KEYBOARD_NOKEYS}, {@link #KEYBOARD_QWERTY},
* {@link #KEYBOARD_12KEY}.
*/
public int keyboard;
/**
* A flag indicating whether any keyboard is available. Unlike
* {@link #hardKeyboardHidden}, this also takes into account a soft
* keyboard, so if the hard keyboard is hidden but there is soft
* keyboard available, it will be set to NO. Value is one of:
* {@link #KEYBOARDHIDDEN_NO}, {@link #KEYBOARDHIDDEN_YES}.
*/
public int keyboardHidden;
所以,我认为如果键盘换成键盘键,键盘就会改变
消息来源的另一部分说:
/**
* The kind of keyboard attached to the device.
* One of: {@link #KEYBOARD_NOKEYS}, {@link #KEYBOARD_QWERTY},
* {@link #KEYBOARD_12KEY}.
*/
public int keyboard;
/**
* A flag indicating whether any keyboard is available. Unlike
* {@link #hardKeyboardHidden}, this also takes into account a soft
* keyboard, so if the hard keyboard is hidden but there is soft
* keyboard available, it will be set to NO. Value is one of:
* {@link #KEYBOARDHIDDEN_NO}, {@link #KEYBOARDHIDDEN_YES}.
*/
public int keyboardHidden;
因此,您可以尝试android:configChanges=“keyboard | uiMode”
而不是android:configChanges=“keyboardHidden | uiMode”
不幸的是,我没有适配器将键盘插入我的设备并检查我的理论。那就试试吧