I have used the following code for enabling Bluetooth (as described here) and the same runs in onCreate() of the launcher activity of my app -
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, 101);
Now the problem is when this dialog is popped up, then every time i rotate the device, the dialog gets created again again on top of the previously created dialog.
I am preventing my activity from getting recreated by handling it from manifest
android:configChanges="orientation|screenSize|keyboardHidden"
This doesn't occur in all devices I am getting this on : LG Nexus 5, Samsung Galaxy Grand
And not on : Samsung I9500 Galaxy S4
Edit : Found this Reported Issue but couldn't find the solution Here is the link
Created another issue Here
It seems this bug was never solved !!
I have tested this on several devices including latest Pixel device and it still exists
And the same has been raised several time on code.google.com/p/android
Reference to raised issues :
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)
In case anyone finds a solution then please do post it here