ravi93
Member
Hii,
I am facing an issue to connect paired Bluetooth device in android 14, Please help me to find proper solution
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
If i am trying to connect with paired device it throw exception is:
Device Connection Failed: (IOException) java.io.IOException: read failed, socket might closed or timeout, read ret: -1
			
			I am facing an issue to connect paired Bluetooth device in android 14, Please help me to find proper solution
			
				Request permission:
			
		
		
		Private rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
rp.CheckAndRequest("android.permission.BLUETOOTH_CONNECT")
rp.CheckAndRequest("android.permission.BLUETOOTH_SCAN")
rp.CheckAndRequest("android.permission.ACCESS_FINE_LOCATION")
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = True Then
        Log(rp.GetSafeDirDefaultExternal(""))
    End If
			
				Bluetooth connection:
			
		
		
		private Sub ListViewPairedDevice_ItemClick(Position As Int, Value As Object)
    Dim bluetoothMac As String = PairedDevices.Get(Value)
    device = bluetoothMac
    connecToDevice(bluetoothMac)
End Sub
'This method will try to connect selected bluetooth devices
private Sub connecToDevice(bluetoothMac As String)
    ButtonConnect.Enabled=False
    Try
        serial.Connect(bluetoothMac)
        ToastMessageShow("Device: " & device & "   connecting",False)
    Catch
        Dim ex As Exception
        ex = LastException
        Log("Exception: " & ex.Message)
        ToastMessageShow("Device not available",True)
    End Try
End Sub
Sub Serial_Connected (Success As Boolean)
    Try
        If Success Then
            Log("Device Connection Successful")
        Else
            Log("Device Connection Failed: " & LastException)
            ToastMessageShow("Device: " & device & "  not connected",True)
            timerConnect.Enabled=False
        End If
    Catch
        Log(LastException)
    End Try
    ListViewPairedDevice.Visible=False
End SubIf i am trying to connect with paired device it throw exception is:
Device Connection Failed: (IOException) java.io.IOException: read failed, socket might closed or timeout, read ret: -1
 
				 
 
		 
 
		 
 
		