1

我用下面的代码实现蓝牙(as described here)重新对屏幕旋转(方向更改),并在的onCreate()我的应用程序的发射活动的同时运行 -蓝牙权限请求对话框 -

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

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

我阻止我的活动从得到重建从清单

android:configChanges="orientation|screenSize|keyboardHidden" 

处理呢?这不会发生在所有的设备 我收到此有关: LG的Nexus 5,三星Galaxy大

而不是: 三星I9500的Galaxy S4

编辑: 发现这个报告的问题,但无法找到解决 Here is the link

创造了另一个问题Here

回答

1

看来这个错误是永远不会得到解决!
我曾在多个设备上,包括最新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)


如果有人发现解决方案那么请张贴在这里

0

当我们转动装置,其CONFIGRATION变化的方法是在活动的呼叫。 你只需要添加android:configChanges="orientation"在您的活动元素AndroidManifest.xml

<activity 
      android:name=".MainActivty" 
      android:configChanges="orientation" 
      android:label="@string/app_name"></activity> 

我希望它会帮助你解决问题

+1

我已经处理了“onConfigurationChanged”中的配置更改。所以我认为这不会有帮助! – shadygoneinsane

+0

一次又一次创建的对话框位于onResume()函数或任何其他函数中 –

+1

由于我的活动未获得重新创建,因此保存用于创建对话框的代码的onResume()或onCreate()不会再次在设备上调用回转.. – shadygoneinsane