BluetoothAdapter.ACTION_REQUEST_ENABLE calls onActivityResult immediately
android, bluetooth
Solution
startActivityForResult doesn't work with singleInstance. Is your activity configured as single instance ? (android:launchMode="singleInstance")
Problem
According to the developer guides, a request can be made to enable Bluetooth as such: http://developer.android.com/guide/topics/connectivity/bluetooth.html#SettingUp ``` if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } ``` In my implementation this creates the request properly and the user is presented with the request dialog. My problem is that onActivityResult() is immediately called such that before the dialog even appears I have the result. The returned requestCode matches the one set (9001 in this case) and the resultCode is always 0 (Activity.RESULT_CANCELED). I believe this to be a bug in 4.3, unfortunately I only have 4.3 devices. Reading the descriptions and the source it appears that onActivityResult() should not be called until the user interacts with the dialog so can anyone confirm this is a bug or explain what I am doing wrong? Tested on the following with the same result: - New Nexus 7 - Nexus 7 - Nexus 4 - Galaxy Nexus