8
votes

I am looking for a way to initiate the audio connection between the Android phone and my headset within my application. The idea is to simplify the connection process in such a way that the user doesn't have to go through the different settings menus anymore (Apps -> Settings -> Wireless & Networs -> Bluetooth settings).

Both devices are supposed to be already paired and the Bluetooth address of the headset to be known.

As far as I learned, the Bluetooth capabilities (available since version 2.0 of the Android SDK) are restricted to Bluetooth discovery and the connection of RFComm channels (host/client) between the Android phone and a Bluetooth device. Is there another way to request Bluetooth profiles on the Android system to initiate a connection to a known device from an app or is this impossible?

2
Did you find an answer for this?JonatanEkstedt

2 Answers

1
votes

Have you looked at the BluetoothAdapter class? It seems like you can do everything you need via that class, unless I misunderstand the question.

As for initiating a connection to a specific device, won't the phone auto-pair with the known device once you enable bluetooth?

0
votes

I'm using follow code to get IBluetooth service, and it has sevral function including connect headset.

IBinder b = ServiceManager.getService("bluetooth");
if (b != null) {
        IBluetooth mBluetoothService = IBluetooth.Stub.asInterface(b);
    }

But, these apis are hidden for app level, and they are different on different android sdk version.You must comply the code in android whole source enviroment, or use reflection to access them.