Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public Page2 As B4Xpage2
' NFC
Private prevIntent As Intent
Private nfc As NFC
Private TagTech As TagTechnology
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Foreground ' instead of Activity_Resume
'forces all nfc intents to be sent to this activity
nfc.EnableForegroundDispatch
Dim si As Intent = B4XPages.GetNativeParent(Me).GetStartingIntent '' instead of 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