#Region Project Attributes
#ApplicationLabel: B4A Example
#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
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
End Sub
Sub Activity_Create(FirstTime As Boolean)
CheckGallery("XYZalbum", "junk.jpg", "image/jpeg")
Wait For CheckGallery_Complete_jpeg
CheckGallery("XYZalbum", "junk.mp4", "video/mp4")
Wait For CheckGallery_Complete_mp4
End Sub
Sub CheckGallery (AlbumName As String, TargetName As String, MimeType As String)
Dim p As Phone
Log(p.SdkVersion)
If p.SdkVersion >= 29 Then
Dim cr As ContentResolver
cr.Initialize("cr")
Dim MediaStore As JavaObject
If MimeType = "image/jpeg" Then
MediaStore.InitializeStatic("android.provider.MediaStore.Images$Media")
Else
MediaStore.InitializeStatic("android.provider.MediaStore.Video$Media")
End If
Dim EXTERNAL_CONTENT_URI As Uri = MediaStore.GetField("EXTERNAL_CONTENT_URI")
Dim Cur As Cursor
Cur = cr.query(EXTERNAL_CONTENT_URI, Array As String("_size"), "relative_path = ? AND _display_name = ?", Array As String("Pictures/" & AlbumName & "/", TargetName), "")
Cur.Position = 0
If Cur.GetString2(0) = Null Then
Log(AlbumName & " " & TargetName & " does not exist")
Else
Log(AlbumName & " " & TargetName & " exists")
End If
End If
If MimeType = "image/jpeg" Then
CallSubDelayed(Me, "CheckGallery_Complete_jpeg")
Else
CallSubDelayed(Me, "CheckGallery_Complete_mp4")
End If
End Sub