-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
I have 2 paired Android devices, and I have this code:
mSmoothBluetooth = new SmoothBluetooth(this, SmoothBluetooth.ConnectionTo.ANDROID_DEVICE, SmoothBluetooth.Connection.SECURE, mListener);
mSmoothBluetooth.tryConnection();
private SmoothBluetooth.Listener mListener = new SmoothBluetooth.Listener() {
@Override
public void onBluetoothNotSupported() {
//device does not support bluetooth
}
@Override
public void onBluetoothNotEnabled() {
//bluetooth is disabled, probably call Intent request to enable bluetooth
}
@Override
public void onConnecting(Device device) {
//called when connecting to particular device
Log.w("DEBUG","Connecting to device "+device.getName());
}
@Override
public void onConnected(Device device) {
//called when connected to particular device
Log.w("DEBUG","Connected device "+device.getName());
}
@Override
public void onDisconnected() {
//called when disconnected from device
}
@Override
public void onConnectionFailed(Device device) {
//called when connection failed to particular device
Log.w("DEBUG","Connection failed to device "+device.getName());
}
@Override
public void onDiscoveryStarted() {
//called when discovery is started
}
@Override
public void onDiscoveryFinished() {
//called when discovery is finished
}
@Override
public void onNoDevicesFound() {
//called when no devices found
}
@Override
public void onDevicesFound(List list, SmoothBluetooth.ConnectionCallback connectionCallback)
{
Log.w("DEBUG","Found devices");
if(list.size()==1)
{
Log.w("DEBUG", "Found 1 device");
Log.w("DEBUG", "Device is paired: "+list.get(0).isPaired());
connectionCallback.connectTo(list.get(0));
}
}
@Override
public void onDataReceived(int data) {
//receives all bytes
}
};
I always get this log:
D/BluetoothManager? Paired devices: 1 W/DEBUG? Found devices W/DEBUG? Found 1 device W/DEBUG? Device is paired: true W/DEBUG? Connecting to device GT-S5830i D/BluetoothService? setState() 0 -> 1 D/BluetoothService? setState() 1 -> 2 D/BluetoothService? setState() 2 -> 1 W/DEBUG? Connection failed to device GT-S5830i
Why does the connection fail if they are paired already?
Metadata
Metadata
Assignees
Labels
No labels