I'm updating one of my apps to target SDK 28 (it previously didn't have a target) and the code which gets the name of the connected device no longer works on my Android 9 device but still works on Android 5 and 6.
The error is :
Anybody have any idea how I get the address, or maybe there is a better way of getting the device name now that I don't know?
Thanks in advance
errors on connectedAddress = ref.GetField("mAddress"):
Private Sub serial1_Connected (Success As Boolean)
If Success Then
Dim devices As Map
devices = serial1.GetPairedDevices
Dim i As Int
Dim ref As Reflector
Dim connectedAddress As String
Dim workingsocket As Object
ref.Target = serial1
workingsocket = ref.GetField("workingSocket")
ref.Target = workingsocket
connectedAddress = ref.GetField("mAddress")
For i = 0 To devices.Size - 1
Dim address As String
address = devices.GetValueAt(i)
If address = connectedAddress Then
connectedDevice = devices.GetKeyAt(i)
End If
Next
BTStatus = "Connected to " & connectedDevice
BTLog("Connected to " & connectedDevice & " at " & DateTime.Time(DateTime.Now), False)
BTConnected = True
StartAStream(serial1.InputStream, serial1.OutputStream)
Else
retries = retries + 1
BTStatus = "Connection failed, retrying " & retries
'BTLog("Error: " & LastException.Message, False)
If retries >= 10 Then
serial1.StopListening
BTLog("Bluetooth listener failed. Please exit the app and try again.", False)
retries = 0
End If
End If
UpdateUI
End Sub
The error is :
java.lang.NoSuchFieldException: No field mAddress in class Landroid/bluetooth/BluetoothSocket; (declaration of 'android.bluetooth.BluetoothSocket' appears in /system/framework/framework.jar)
Anybody have any idea how I get the address, or maybe there is a better way of getting the device name now that I don't know?
Thanks in advance
Last edited: