Android Question ContentChooser - select multiple photos

Discussion in 'Android Questions' started by red30, Jul 23, 2018.

  1. red30

    red30 Active Member Licensed 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.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    As you can see in that thread it didn't work with most file explorers.

    You cannot add this flag to ContentChooser.
     
  3. red30

    red30 Active Member Licensed User

    I see. So how can I add several photos using ContentChooser? Could you help me?
     
    Last edited: Jul 23, 2018
  4. sz4t4n

    sz4t4n Member Licensed User

  5. red30

    red30 Active Member Licensed User

  6. Erel

    Erel Administrator Staff Member Licensed User

    No.
     
  7. red30

    red30 Active Member Licensed User

  8. red30

    red30 Active Member Licensed User

    Are there any other ways to add many photos at the same time?
     
  9. KMatle

    KMatle Expert Licensed User

    Last edited: Jul 25, 2018
    red30 likes this.
  10. red30

    red30 Active Member Licensed User

    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?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    KMatle and red30 like this.
  12. red30

    red30 Active Member Licensed User

    Can you give any example?
    I dont understand how to use StartActivityForResult with EXTRA_ALLOW_MULTIPLE...
    Code:
    #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: Jul 27, 2018
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice