I am trying to make an A2DP connection automatically from my android app. I developed a test app that tries to connect with audio sink. It does not connect successfully. i have a ubuntu system as audio sink which is paired with the mobile already. i have hard coded the mac address of the ubuntu system. this is the code,

private static String address = "xx_xx_xx_xx_xx_xx_xx";
private static final UUID MY_UUID = UUID.fromString("00000110A-0000-1000-8000-00805F9B34FB");

inside onCreate

mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);

btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);


it throws an error "service discovery failed".

Can anyone of you please help me on this.?.

thanks in advance,