Android Question Get BT Paired list in Service

Scantech

Well-Known Member
Licensed User
B4X:
            Dim tmpSerial1 As Serial: tmpSerial1.Initialize("")
            Dim PairedDevices As Map
            PairedDevices.Initialize
            PairedDevices = tmpSerial1.GetPairedDevices
         
            Dim l As List: l.Initialize
            For I = 0 To PairedDevices.Size - 1
                l.Add(PairedDevices.GetKeyAt(I))
            Next
     
            Dim sf81 As Object = InputListAsync(l, "Choose Device", -1, True)
            Wait For (sf81) InputList_Result(Ret As Int)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference
The above code will not work in Service, but works fine in the activity. Any reason for that?
 
Top