Reputation: 1513
I'm trying to read data from Bluetooth device, first I installed "S2 Bluetooth term3" which works very nice..
Now I'm trying to read data from my own application creating a socket so:
mSocket = device.createRfcommSocketToServiceRecord(device.getUuids()[0].getUuid());
But, doesn't work, I got this:
Service discovery failed
I've read several posts and I've tried this:
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
mSocket = (BluetoothSocket) m.invoke(device, 1);
And I got this:
Permission denied
This fails on this line:
mSocket.connect();
The UUID of my device is: 00000111-0000-1000-8000-00805f9b34bf
Thanks.
Upvotes: 1
Views: 245
Reputation: 1513
I got it, since Android 4.0.4 (API 10) is necessary to use:
createInsecureRfcommSocketToServiceRecord(...)
instead of:
createRfcommSocketToServiceRecord(...)
Now my app works!
Upvotes: 1
Reputation: 11
Do you have the proper permissions in the manifest?
`<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />`
Upvotes: 0