'Declare my Event which is in the Main Activity.
#Event: ImageGalleryFileSelected(strRealFilePathName as string, strVirtualFilePathName as string)
Sub Class_Globals
Private Caller_ As Object 'The Main Activity.
Private strEventName_ As String 'The event prefix.
End Sub
Public Sub Initialize(Caller As Object,strEventName As String)
Caller_ = Caller 'Get my Main Activity
strEventName_ = strEventName 'Get my event prefix.
End Sub
Public Sub ShowImageGallery()
'Prompt the user with a message box to grant permission for access to external storage.
RequestPermissionToReadExtStorage
'Show the Device's Image Gallery.
Dim chooser As ContentChooser
If chooser.IsInitialized = False Then
chooser.Initialize("chooser")
End If
chooser.show("image/*", "Choose Image")
Wait For(chooser) chooser_Result (Success As Boolean, Dir As String, FileName As String)
If Success Then
Dim strRealFilePathName As String = GetRealFilePathNameFromContentChooser(FileName)
Dim strVirtualFilePathName As String = Dir & ";" & FileName
'Call my Event in the Main Activity <----- This only works when I step it with a Break Point.
CallSubDelayed3(Caller_, strEventName_ & "_ImageGalleryFileSelected",strRealFilePathName,strVirtualFilePathName)
Else
'No image was selected.
End If
End Sub
Public Sub RequestPermissionToReadExtStorage
RuntimePermission.CheckAndRequest(RuntimePermission.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
Sleep(50)
End Sub