Hi,
I have a trouble with an app that read NFC tag.
After I have read a nfc tag, I must insert a quantity inside an edit text, so, after the read I call IME.showkeyboard(edittext).
If the app is on, all work fine, if the app is paused and it is resumed with the reading of a tag, the keyboard don't show up. If I click into the edittext all work fine everytime.
I show here a sample code that have the same trouble.
Thank you for your important help.
Grazie
marco
I have a trouble with an app that read NFC tag.
After I have read a nfc tag, I must insert a quantity inside an edit text, so, after the read I call IME.showkeyboard(edittext).
If the app is on, all work fine, if the app is paused and it is resumed with the reading of a tag, the keyboard don't show up. If I click into the edittext all work fine everytime.
I show here a sample code that have the same trouble.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim uidp As String
Dim tag As Boolean
Dim conv As ByteConverter
Private prevIntent As Intent
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private nfc As NFC
Private TagTech As TagTechnology
Dim ime As IME
Private Edt1 As EditText
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
nfc.EnableForegroundDispatch
Log("----Activ_res----")
tag=False
uidp=""
''''''''''''''''''''''''''''''''''''''''''''''''''''GESTIONE TAG
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
If techs.IndexOf("android.nfc.tech.NfcV") > -1 Then
TagTech.Initialize("TagTech", "android.nfc.tech.NfcV" , si)
'Connect to the tag
'TagTech.Connect
Dim jo As JavaObject = TagTech
'erel
Log(GetType(jo))
Log(jo.RunMethod("getResponseFlags", Null))
''''''
Dim tagNfc As JavaObject = jo.RunMethod("getTag", Null)
Dim afi As Byte =jo.RunMethod("getResponseFlags", Null)
Dim rawId() As Byte = tagNfc.RunMethod("getId", Null)
Dim uid As String
uid=conv.HexFromBytes(rawId)
'Log(uid)
uidp=uid.ToUpperCase.SubString2(14,16)&uid.ToUpperCase.SubString2(12,14)&uid.ToUpperCase.SubString2(10,12) _
&uid.ToUpperCase.SubString2(8,10)&uid.ToUpperCase.SubString2(6,8)&uid.ToUpperCase.SubString2(4,6) _
&uid.ToUpperCase.SubString2(2,4)&uid.ToUpperCase.SubString2(0,2)
Log(uidp)
tag=True
End If
End If
If tag Then
ime.ShowKeyboard(Edt1)
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
ime.HideKeyboard
End Sub
Thank you for your important help.
Grazie
marco