I am trying to set up access to list, read and delete files in DCIM/Camera
I have in Process_Globals:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
In Main I have:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Getfolder is called by a button click.
When it is called I get a dialog asking what folder I want - I hit the button and then nothing.
The ion_Event is never called.
Also GetBA returns an object with a null activity property.
I'm ripping my hair out and Copilot seems confused - or I am confusing it most likely.
			
			I have in Process_Globals:
			
				B4X:
			
		
		
		    Public treeUri As Uri
    Private ion As Object
	In Main I have:
			
				B4X:
			
		
		
		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 ion_Event(MethodName As String, Args() As Object) As Object
    Dim resultCode As Int = Args(0)
    Dim data As Intent = Args(1)
    If resultCode = -1 And data.IsInitialized Then
        Dim joIntent As JavaObject = data
        treeUri = joIntent.RunMethod("getData", Null)
                'Log("Selected folder URI: " & treeUri.ToString)
        ' Persist access
        Dim flags As Int = Bit.Or(1, 2)
        Dim jo As JavaObject
        jo.InitializeContext
        jo.RunMethod("takePersistableUriPermission", Array(treeUri, flags))
    Else
        Log("Picker cancelled or failed.")
    End If
    Return Null
End Sub
Public Sub Getfolder()
        Dim i As Intent
        i.Initialize("android.intent.action.OPEN_DOCUMENT_TREE", "")
        Log("Intent initialized: " & (i <> Null))
        Dim jo As JavaObject = i
        jo.RunMethod("addFlags", Array(Bit.Or(Bit.Or(1, 2), 8)))
        Dim ctx As JavaObject = GetBA
        Dim ion As Object = ctx.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
        ctx.RunMethod("startActivityForResult", Array(ion, i))
       
    End If
   
End Sub
	Getfolder is called by a button click.
When it is called I get a dialog asking what folder I want - I hit the button and then nothing.
The ion_Event is never called.
Also GetBA returns an object with a null activity property.
I'm ripping my hair out and Copilot seems confused - or I am confusing it most likely.