蓝牙权限请求对话框 - 在屏幕旋转时重新创建(方向更改)

Bluetooth permission request dialog - recreated on screen rotation(orientation change)

我使用了以下代码来启用蓝牙 (as described here),并且在我的应用 activity 的启动器的 onCreate() 中运行了相同的代码 -

Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, 101);

现在的问题是当弹出这个对话框时,每次我旋转设备时,都会在之前创建的对话框之上再次创建该对话框。

我通过从清单

处理它来防止我的 activity 被重新创建
android:configChanges="orientation|screenSize|keyboardHidden"

并非所有设备都会出现这种情况 我正在接受这个: LG Nexus 5、三星 Galaxy Grand

而不是: 三星 I9500 盖乐世 S4

编辑: 找到此报告的问题但找不到解决方案 Here is the link

创建了另一个问题 Here

当我们旋转设备时,其配置更改方法是在 activity 中调用。 您只需要在 AndroidManifest.xml

中的 activity 元素中添加 android:configChanges="orientation"
<activity
            android:name=".MainActivty"
            android:configChanges="orientation"
            android:label="@string/app_name"></activity>

希望能帮到您解决问题

看来这个错误一直没有解决!!
我已经在包括最新 Pixel device 在内的多个设备上对此进行了测试,它仍然存在
code.google.com/p/android 上多次提出同样的问题

参考提出的问题:
Issue 60002: Bluetooth permission request dialog

Issue 219105 On each rotation, dialog for requesting user permission to enable Bluetooth, the request dialog is placed on the top of the stack

Issue 24931: Bluetooth permission request dialog - recreated on screen rotation(orientation change)


如果有人找到解决方案,请在此处post解决