Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to access the bluetooth in android [enable() or disable()] without the user interaction?

I am developing an Android application which will access the Bluetooth to enable and disable it without any user interaction. Can somebody help me on how to do it?

like image 303
Edu Avatar asked Apr 20 '12 16:04

Edu


People also ask

What permissions are required to access Bluetooth?

Discover local Bluetooth devices If you want your app to initiate device discovery or manipulate Bluetooth settings, you must declare the BLUETOOTH_ADMIN permission. Most apps need this permission solely for the ability to discover local Bluetooth devices.

How do I know if my Android Bluetooth is enabled?

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.

How do I get permission to scan for Bluetooth?

1- If you want to search nearby Bluetooth devices, you must add BLUETOOTH_SCAN permission. 2- If you want your device to be discovered by other devices, you must add BLUETOOTH_ADVERTISE permission. 3- If you want your device to be communicable with other devices, you must add BLUETOOTH_CONNECT permission.


1 Answers

You can do this by using BluetoothAdapter:

    BluetoothAdapter.getDefaultAdapter().disable();
    BluetoothAdapter.getDefaultAdapter().enable();

And add ths permission to manifest:

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
like image 167
Chemik Avatar answered Oct 09 '22 10:10

Chemik