12

Bluetooth keyboard will cause activity destroy and recreate if I turn off it or far away from pad(Android) Activity will be recreate how can i avoid this problem

1
24

In contrast to the accepted answer, I found that keyboard|keyboardHidden was not enough. I was working with a Logitech Bluetooth keyboard (model #JNZYR0021).

What did work was this:

<activity
  ...
  android:configChanges="orientation|screenSize|keyboard|keyboardHidden|navigation"
/>

Apparently this Logitech keyboard also changes navigation, which is weird because the Android docs say:

The navigation type (trackball/dpad) has changed. (This should never normally happen.)

Go figure.

5
  • i added the statement which you suggested, but native key board not opening for edittext which are in that activity. Aug 18, 2015 at 9:32
  • Thanks for you answer. It helped. Apr 21, 2016 at 11:05
  • I spent weeks trying to find this issue. Touch when the customer fails to mention they were using a bluetooth keyboard. Thanks! Jun 30, 2016 at 23:45
  • Terrific.. How did you manage to know that navigation was changed? Feb 6, 2017 at 11:22
  • 1
    I also spent days trying to resolve this problem. Adding "keyboard|keyboardHidden|navigation" is what solved it for me.
    – J Avery
    Feb 26, 2018 at 21:59
19

Pairing a Bluetooth keyboard is considered to be a configuration change: Try adding the below to your AndroidManifest.xml

android:configChanges="keyboard|keyboardHidden"

From: http://developer.android.com/guide/topics/manifest/activity-element.html#config android:configChanges

1
  • Helped with keyboard connected via USB as well. Thanks!
    – Natalia
    Jan 29, 2019 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.