Connecting to Mac OSX using an Android phone
I am writing some code to connect my Android device to my Mac using bluetooth. Its seems to create a connection,(i am able to see my android in tbe connected list in Mac) But it throws an exception on the androi开发者_开发技巧d device.
BluetoothDevice bd = mBluetoothAdapter.getRemoteDevice("00:26:08:BF:D0:22");
BluetoothSocket bs = null;
try {
bs = bd.createRfcommSocketToServiceRecord(DeviceSearchService.MY_UUID);
try {
bs.connect();
} catch (IOException ex) {
Log.i(TAG, "Exception in connecting to socket." + ex.getMessage(), ex);
}
}
The bs.connect is throwing an exception saying cannot connect to the device. The device in question is a Mac OSX laptop of mine. I am running this code from Galaxy S device. THe UUID used is "00001101-0000-1000-8000-00805F9B34FB"
Am I missing something ?
have you declared the Bluetooth permissions in your application manifest file?
<manifest ... >
<uses-permission android:name="android.permission.BLUETOOTH" />
...
</manifest>
精彩评论