Reputation: 227
In android application we are using Bluetooth connectivity with some of medical devices.
To do this we have used below code
BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bluetoothAddress);
Method m = (Method) zee.getClass().getMethod("createRfcommSocket",new Class[] { int.class });
result = (BluetoothSocket) m.invoke(zee, Integer.valueOf(1));
or some condition, if the above code get failed then we use below code
String bluetooth_address="";
bluetooth_address=bluetoothAddress;
BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bluetooth_address);
result = zee.createRfcommSocketToServiceRecord( getSerialPortUUID() );
both codes are working fine up to 4.0 android OS.
But on Android OS 4.1.1 it is now getting issue like “Connection Refused
”.
Please help.
Upvotes: 3
Views: 1656
Reputation: 227
Thanks all, I solved this issue by calling insecure RF comm Socket like
String bluetooth_address="";
bluetooth_address=bluetoothAddress;
BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bluetooth_address);
//result = zee.createRfcommSocketToServiceRecord( getSerialPortUUID() );
result = zee.createInsecureRfcommSocketToServiceRecord(getSerialPortUUID());
Upvotes: 0
Reputation: 7634
There were issues with bluetooth in version 4.2 and presumably 4.1.1. In version 4.2.1 they have been resolved. Check http://crave.cnet.co.uk/mobiles/android-4-2-1-update-brings-back-december-fixes-bluetooth-50009859/. Try in 4.2.1
Upvotes: 1