Android Question NFC example problem.

AlexG

Member
Licensed User
Longtime User
Hi everyone. I have been trying to convert an application from QR code to NFC, so I downloaded Erel's example project and compiled it. However I seem to get an error that confuses me. Is there also an updated NFC example under B4XPages?

Call me stupid, and I probably overlooked something really, really, basic and stupid ... But can anyone tell me what has happened here?



Line 38 is actually line 3 as highlighted in the code below.

B4X:
ub Activity_Resume
    'forces all nfc intents to be sent to this activity
    nfc.EnableForegroundDispatch
    Dim si As Intent = Activity.GetStartingIntent
    'check that the intent is a new intent
    If si.IsInitialized = False Or si = prevIntent Then Return
    prevIntent = si
    If si.Action.EndsWith("TECH_DISCOVERED") Or si.Action.EndsWith("NDEF_DISCOVERED") Or si.Action.EndsWith("TAG_DISCOVERED") Then
        Dim techs As List = nfc.GetTechList(si)
        Log($"Techs: ${techs}"$)
        'in this case we are only accessing Ndef tags.
        If techs.IndexOf("android.nfc.tech.Ndef") > -1 Then
            TagTech.Initialize("TagTech", "android.nfc.tech.Ndef" , si)
            'Connect to the tag
            TagTech.Connect
        Else
            ToastMessageShow("Tag does not support Ndef.", True)
        End If
    End If
End Sub

Any help would be gratefully appreciated. :)

Thank you.

Alex G.