I want to test if my android device is discoverable before sending the intent that prompts the user to turn it on, what do I do?
the intent is as follows:
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 30);
startActivityForResult(intent, idBlueToothDiscoveryRequest);
Call isEnabled() to check whether Bluetooth is currently enabled. If this method returns false, then Bluetooth is disabled. To request that Bluetooth be enabled, call startActivityForResult() , passing in an ACTION_REQUEST_ENABLE intent action.
Make sure Bluetooth is turned on. Touch and hold Bluetooth . In the list of paired devices, tap a paired but unconnected device. When your phone and the Bluetooth device are connected, the device shows as "Connected."
From the Home screen, tap the Menu key > Settings > Bluetooth. Tap the Bluetooth switch to turn it on. Tap the check box next to your phone's name to make your phone visible to other Bluetooth devices. A list of available devices will be displayed.
I found out:
if(mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
{
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 30);
startActivityForResult(intent, idBlueToothDiscoveryRequest);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With