ContentChooser - Select multiple files

Orlando

Member
Licensed User
Longtime User
Hi,

I have the current code, but i can't found how to solve this in forum. I need to open the default android gallery, select multiple files and get the all paths.

PHP:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      chooser.Initialize("chooser")
           End If
End Sub

Sub chooser_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
       'HERE
       'How can i do a loop here to read all paths selected?        


    Else
        ToastMessageShow("No image selected", True)
    End If
End Sub

Sub btnSelectPictures_Click
   chooser.Show("image/*", "Choose image")
End Sub


Please, i need help.
 

Orlando

Member
Licensed User
Longtime User
Does the gallery app allow you to select multiple images?

When i send an email from any android email client, yes! i can attach multiple files from gallery

nexus-one-gallery-cooliris-share.jpg
 
Upvote 0

Orlando

Member
Licensed User
Longtime User
ContentChooser is based on Intent.ACTION_GET_CONTENT action. This action only supports a single resource.

Thanks! could you recommend me an easy way to upload pictures to a server?

Insert as base64 in a database? ftp?

what is better?
 
Upvote 0

Orlando

Member
Licensed User
Longtime User
Both options are possible. It really depends on your exact requirements.


Thanks... back to ContentChooser... i've a problem.

When i take a photo, and open the android gallery with ContentChooser, the picture isn't visible.

If i open an alternative gallery (like QuickPic) i can see the photo!!

how can i set the "QuickPic app" as default gallery for ContentChooser? without prompt a dialog? (I'can't uninstall the android gallery, i can't root the tablet)

please advise.
 
Upvote 0

Orlando

Member
Licensed User
Longtime User
Are you using CameraEx class? In the example code, an intent is sent to force the media scanner to scan the saved image. This should add the image to the gallery.

No, I've a crash on Android 4.1 with CameraEX, so i use this code to take picture and re-scan: (Thanks)

B4X:
Dim strFile As String

   'random filename
   strFile = DateTime.Now
   
   Module.OpenCam(File.DirRootExternal & "/DCIM/Camera", strFile & ".jpg")


B4X:
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub OpenCam(Directory As String, PictureName As String)

    Dim i As Intent

    i.Initialize("android.media.action.IMAGE_CAPTURE", "")
    i.PutExtra("output", ParseUri("file://" & File.Combine(Directory, PictureName)))
   
                
    StartActivity(i)
   
   ScanFiles(Array As String(File.Combine(Directory, PictureName)))
                
End Sub

Sub ParseUri(FileName As String) As Object

    Dim r As Reflector

    Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(FileName), Array As String("java.lang.String"))

End Sub

Sub ScanFiles(files() As String)
    Dim r As Reflector
    r.RunStaticMethod("android.media.MediaScannerConnection", "scanFile", _
        Array As Object(r.GetContext, files, Null, Null), _
        Array As String("android.content.Context", "[Ljava.lang.String;", "[Ljava.lang.String;", _
            "android.media.MediaScannerConnection$OnScanCompletedListener"))
End Sub
 
Upvote 0
Top