Android Question ContentChooser - select multiple photos

red30

Well-Known Member
Licensed User
Longtime User
I found two topics (1,2) about the choice of several files but didnt found the answer. Can I choose several files using ContentChooser? Here was written about EXTRA_ALLOW_MULTIPLE. Can I add this function to ContentChooser? I need to add 10-15 photos at a time in my app, and it is very long to add them one at a time.
 

red30

Well-Known Member
Licensed User
Longtime User
As you can see in that thread it didn't work with most file explorers.

You cannot add this flag to ContentChooser.
I see. So how can I add several photos using ContentChooser? Could you help me?
 
Last edited:
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
You can do it vice versa: Make your app able to receive other apps shared content (see the examples). Then the user can select n images from the gallery and press share. Your app can then receive all the images. I did that in one app. Works like a charm.

https://www.b4x.com/android/forum/t...ple-image-s-shared-to-your-app.91612/#content
Thank you, but it will not work for me. I have a lot of activities and a lot of CustomListView containing photos (https://www.b4x.com/android/forum/threads/remove-item-from-customlistview.94079/). I need that when I click a button in CustomListView all those photos are loaded.

Is it even possible to do this with B4A?
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Can you give any example?
I dont understand how to use StartActivityForResult with EXTRA_ALLOW_MULTIPLE...
B4X:
#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 ion As Object
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    ShowPicker
End Sub
Sub ShowPicker
    Dim i As Intent
    i.Initialize("android.intent.action.GET_CONTENT", "")
    StartActivityForResult(i)
End Sub
Sub ion_Event (MethodName As String, Args() As Object) As Object
    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("android.intent.extra.ringtone.PICKED_URI"))
        Log(uri)
    End If
    Return Null
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

There are very few examples on the forum with StartActivityForResult. I can not understand how this works.
 
Last edited:
Upvote 0
Top