Bug 25888 - [Android] Connecting a bluetooth keyboard causes navigation to reset to the root
Summary: [Android] Connecting a bluetooth keyboard causes navigation to reset to the root
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.5
Hardware: PC Mac OS
: Highest blocker
Target Milestone: ---
Assignee: Bugzilla
: 31383 ()
Depends on:
Reported: 2015-01-09 13:41 UTC by John Miller [MSFT]
Modified: 2017-11-14 15:54 UTC (History)
15 users (show)

Tags: ac, Android
Is this bug a regression?: ---
Last known good build:

Test Case (177.70 KB, application/zip)
2015-01-09 13:41 UTC, John Miller [MSFT]
Non-Forms test case (20.08 KB, application/zip)
2015-01-16 15:17 UTC, John Miller [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description John Miller [MSFT] 2015-01-09 13:41:33 UTC
Created attachment 9305 [details]
Test Case


   Connecting a bluetooth keyboard to the android device while the Forms app is running will cause the navigation to reset to the root. 

**Steps to Reproduce:**

   1. Open the attached sample. 
   2. Run it on an Android Device (I used a Nexus 5 with API 21, turn on Bluetooth on the device)
   3. Pair a bluetooth keyboard with your device.
   4 Switch back to the running app. 
   5. Press Go to Page Two (Keep doing this until you are at Page 4)
   6. Turn off your paired keyboard. 
   7. Turn it back on, and it should auto-connect back to your device. 

**Actual Results:**

   When the keyboard auto-connects to the device in step 7 above, the navigation hierarchy in the app resets to the Page One. 

**Expected Results:**

   The app should stay on Page Four. 

**Build Date & Platform:**

   XF 1.3.1

**Additional Information:**

   I was able to reproduce this using my Apple wireless keyboard and my Nexus 5.
Comment 1 Abhishek 2015-01-13 13:11:55 UTC
I have tried this issue and able to reproduce the reported behavior at my end.

Steps to Reproduce:
1. Open the attached sample.
2. Run it  on an Android Device.
3. Pair a Bluetooth Keyboard with the device.
4. Switch  back to the  running application. 
5. Press Go to Page Two, keep on pressing the button until you reach the last page.
6. Turn off the paired keyboard.
7. Turn it back on, Bluetooth keyboard  auto connect back to the device.
8. It should stay on page four but it reset to page One.

Device Log: https://gist.github.com/Abhishekk360/e597338aecbaeadbcca1

Build Info:

=== Xamarin Studio ===

Version 5.7 (build 661)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 7c4c2c5
Build date: 2015-01-08 22:29:16-0500

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 John Miller [MSFT] 2015-01-16 15:17:49 UTC
Created attachment 9387 [details]
Non-Forms test case

Added a Non-Xamarin.Forms test case that _does not_ reproduce the same issue. This hopefully points to the issue being with Xamarin.Forms.
Comment 3 Jason Smith [MSFT] 2015-02-03 06:16:00 UTC
Can you please try setting the ConfigChanges.Keyboard bit on your activity? I am unfortunately having a heck of a time getting an android device to pair with any of hte BT keyboards I have.
Comment 4 Jon Douglas [MSFT] 2015-02-10 14:47:58 UTC
A customer has informed me that adding ConfigChanges.Keyboard on the Activity does not help in this case nor the sample case above. I'm reopening this bug until further notice. Please let me know if we need anything else and I'll be happy to provide it.
Comment 6 Botond Fazekas 2015-07-31 08:13:49 UTC
Hi, unfortunately despite the status this is still not fixed in XF
The attached test case is still reproducing this issue.
Please review this, it causes a lot of issues for our customers.
Comment 7 Cody Beyer (MSFT) 2016-04-13 16:50:57 UTC
This appears to still be occurring in Forms 2.1.x using the attached test case

Comment 8 David Ortinau [MSFT] 2017-06-16 17:02:28 UTC
I confirmed bad behavior on 2.3.4 and 2.3.5-pre.

This is fixed in master. Tested on nightly build
Comment 9 David Ortinau [MSFT] 2017-06-16 17:04:20 UTC
Apologies, wrong ticket opened in my browser! Ignore that previous comment.
Comment 10 Adam Patridge [MSFT] 2017-06-16 18:13:44 UTC
For sanity's sake, I pulled all the Shared project files into a File->New->Cross-Platform (Shared) solution and updated to the latest Forms stable package: v2.3.4.247. That version exhibited the same restart when a Bluetooth keyboard was connected or disconnected.

I also updated the latest pre-release package, v2.3.5.239-pre3, and confirmed the restart there as well.
Comment 11 Adam Patridge [MSFT] 2017-06-16 22:03:52 UTC
After some discussion, this is actually a standard feature of Android. Device configurations can often cause Android to restart the running Activity, and adding/removing a keyboard is one such configuration change. Activities can tell the OS that they want to handle these changes themselves to avoid that restart.

The default Xamarin.Forms templates are specifically wired up in the Android project to handle the basics of screen size and orientation changes, but you can also decide to add keyboard-related values to prevent these restarts.


In your Android head project, open MainActivity.cs and alter the ConfigurationChanges value in the Activity attribute on the class to include ConfigChanges.Keyboard and ConfigChanges.KeyboardHidden.

[Activity (..., ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden)]

It's probably worth some discussion as to whether this should become part of the File->New templates or not for projects going forward, though.
Comment 12 Samantha Houts [MSFT] 2017-06-20 18:56:17 UTC
*** Bug 31383 has been marked as a duplicate of this bug. ***