I am developing an app to control a custom device. This custom device has a dual mode bluetooth and working in dual mode function for accepting Android and iOS connections.
With Android I need use classic connection. I made some tests with several smartphones and tablets. However, with some tablets models I am have problem to connect.
I have a tablet with MT6572 SOC from MediaTek and it has 4.4.2 android. I also have a SAMSUNG Galaxy Tab E with SC8830 SOC from Spreadtrum and it has 4.4.4 android. Both tablets has API level 19.
I get the adapter this way :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (mBluetoothManager == null) {
mBluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
if (mBluetoothManager == null) {
return false;
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
}
And to connect I code this way:
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
BluetoothSocket socket = device.createRfcommSocketToServiceRecord(myUUID);
socket.connect()
The socket is created successfully, but when I try to connect I receive the following error/message:
java.io.IOException: read failed, socket might closed or timeout, read ret: -1
When I observe the log from my custom device with dual mode bluetooth I see events from a Low Energy connection. It seem that Android is not respecting my attempt of creating socket and classic bluetooth connection.
Is behavior normal this? can be a bug in android?
Thanks