#Region Project Attributes
#ApplicationLabel: ReadPassport
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Private ion As Object
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private Button1 As B4XView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetField("processBA")
End Sub
Sub ReadPassport
Dim i As Intent
i.Initialize("com.tananaev.passportreader.REQUEST", "")
i.PutExtra("passportNumber", "1234567890")
i.PutExtra("dateOfExpiry", "2023-08-09")
i.PutExtra("dateOfBirth", "1962-05-04")
i.PutExtra("photoAsBase64", True)
StartActivityForResult(i)
End Sub
Sub ion_Event (MethodName As String, Args() As Object) As Object
Log("here")
If Args(0) = -1 Then 'resultCode = RESULT_OK
Dim i As Intent = Args(1)
Dim jo As JavaObject = i
Dim uri As String = jo.RunMethod("getParcelableExtra", Array As Object("firstname", "lastname", "gender", "state", "nationality", "photo", "photoBase64" ))
Log(uri)
End If
Return Null
End Sub
Private Sub Button1_Click
ReadPassport
End Sub