Sub Activity_Resume
nfc.EnableForegroundDispatch
Dim si As Intent = Activity.GetStartingIntent
If si.IsInitialized = False Or si = prevIntent Then Return
prevIntent = si
If si.Action.EndsWith("TECH_DISCOVERED") Or si.Action.EndsWith("TAG_DISCOVERED") Then
Dim techs As List = nfc.GetTechList(si)
Log($"Techs: ${techs}"$)
If techs.IndexOf("android.nfc.tech.MifareUltralight") > -1 Then
TagTech.Initialize("TagTech", "android.nfc.tech.MifareUltralight" , si)
TagTech.Connect
Else If techs.IndexOf("android.nfc.tech.MifareClassic") > -1 Then
TagTech.Initialize("TagTech", "android.nfc.tech.MifareClassic" , si)
TagTech.Connect
Else
ToastMessageShow("Tag does not support Ndef.", True)
End If
End If
End Sub
Private Sub TagTech_Connected (Success As Boolean)
Dim key() As Byte = Array As Byte(0xA0,0xA1,0xA2,0xA3,0xA4,0xA5)
Dim sector As Int=0
TagTech.RunAsync("Authenticate", "authenticateSectorWithKeyA", Array(sector, key), 0)
End Sub
Private Sub Authenticate_RunAsync (Flag As Int, Success As Boolean, Result As Object)
Log($"Finished trying to auth. Success=${Success}, Flag=${Flag}"$)
If Success Then
Dim blockIndex As Int=0
TagTech.RunAsync("ReadBlock","readBlock",Array(blockIndex),0)
End If
End Sub
Private Sub ReadBlock_RunAsync(Flag As Int, Success As Boolean, Result As Object)
Log($"Finished trying to read. Success=${Success}, Flag=${Flag}"$)
Log(LastException)
If Success Then
If Result<>Null Then
Dim myBlock() As Byte = Result
End If
End If
End Sub