Recently encountered a bug. After android connects to the bluetooth device, the program unexpectedly exits (only on some nexus devices ).
I found an error at the JNI layer from logcat (my program uses JNI ),
The onDestroy of the activity is called.
This is easy to handle. It must be because the configChange is triggered after the device is connected, and the program does not properly handle this situation.
Check AndroidManifest. xml and find that the configChanges attribute of the activity is
[Plain]
Android: configChanges = "fontScale | keyboard | keyboardHidden | locale | orientation | screenLayout | uiMode | screenSize"
Android: configChanges = "fontScale | keyboard | keyboardHidden | locale | orientation | screenLayout | uiMode | screenSize" contains almost all configChanges, except for mcc, mnc, touchscreen, navigation, smallestScreenSize and layoutDirection.
Here, mcc and mnc cannot be changed theoretically, because I have not moved to the ground;
Touchscreen and navigation are both marked as "This shoshould never normally happen" in the android doc, so they are not considered for the time being;
SmallestScreenSize and layoutDirection are neither theoretically possible.
However, in addition to configChanges which causes the activity to restart, it is impossible to think of other possibilities.
Therefore, the configchanges are added one by one for troubleshooting, and the result is navigation.
Recall that I am connected to a Bluetooth keyboard, which does change the type of navigation.
After connecting to the Bluetooth keyboard, I can use the direction key to navigate.
This is a rare opportunity for people to gain insights and make documents untrusted (especially for android documents ).
However, this problem only occurs on some nexus devices at hand,
It is understandable that, after all, the device is positioned there.
However, considering the penetration rate of nexus devices, the fragmentation problem still persists.