Android Question ContentChooser Event fails [SOLVED]

artsoft

Active Member
Licensed User
Longtime User
Hi!

In one of my activities, I use this ContentChooser in order to select a ZIP file:

B4X:
Sub handleImport()
    Private zipChooser As ContentChooser
    zipChooser.Initialize("zipChooser")
    zipChooser.show("application/zip", "Please select zip file")
End Sub

Sub zipChooser_Result(Success As Boolean, Dir As String, FileName As String)
    If Success Then
        MsgUtils.Info(Dir & " | File: " & FileName)
    Else
        MsgUtils.Info("Cancel")
    End If
End Sub

In my manifest file this permission is set:
AddPermission(android.permission.READ_EXTERNAL_STORAGE)

So I have access to the files and I tried the selection with 5 (!) different file manager apps and each of them allows the selection of the given ZIP, but this method was never triggered:
zipChooser_Result

No message was displayed on GUI after the selection of the ZIP file and no halt at any breakpoint within the debugger ... within this method.

Perhaps, the given mime type is wrong? I also used "zip/*" - but no success.

I am thankful for any help.

Regards
ARTsoft
 

artsoft

Active Member
Licensed User
Longtime User
By the way..............

I also used this with image files in my app:

B4X:
Public cc As ContentChooser
cc.Initialize("imgChooser")
cc.show("image/*", "Choose image")
-----------------------------------------------
Sub imgChooser_Result(Success As Boolean, Dir As String, FileName As String)
    If Success Then
        ...
    Else
        ...
    End If
End Sub

And this works!!!!!! ......... Very strange!

Regards
ARTsoft
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
OK - I found the mistake :)

I moved the declaration of the ContentChooser to Process_Globals
then I checked if ContentChooser is initialized or not

Now it works!

:)
 
Upvote 0
Top