Jump to content

Open android gallery with intent

Recommended Posts

I'm looking for a way to open the Android gallery application from an intent (not the integrated action from Delphi). 
I can open the filepicker from android and reading the result of the intent, but this is  unhandy/too complicated for my users:


This works but i don't like it.

Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_OPEN_DOCUMENT);
Intent.putExtra(TJIntent.JavaClass.EXTRA_LOCAL_ONLY, StringToJString('true')); 
Intent.putExtra(TJIntent.JavaClass.EXTRA_ALLOW_MULTIPLE, True);


For Java I found the following solution, but I do not know how to use this solution in Delphi:


Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);


in delphi: Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_PICK, ?????????);



(Delphi 10.4.1)

Any help would be great.


Share this post

Link to post

I doubt that Delphi has natively imported the MediaStore.Images.Media class, but you should be able to import it manually using Java2OP, then you can access the EXTERNAL_CONTENT_URI field like this, eg:

  pickIntent: JIntent;

// replace TJMediaStore_Images_Media with whatever name Java2OP imports for it...
pickIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_PICK, TJMediaStore_Images_Media.JavaClass.EXTERNAL_CONTENT_URI);


Share this post

Link to post
6 hours ago, Dave Nottage said:

There is already an import for it in the Androidapi.JNI.Provider unit. In Delphi 10.4.1, starting at line 3658

Well, I don't have 10.4.1 installed (or the sources for it), so there you go, just shows how little I know :classic_tongue:

  • Like 1

Share this post

Link to post



I found it in Androidapi.JNI.Provider unit:
intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_PICK,TJImages_Media.JavaClass.EXTERNAL_CONTENT_URI);


Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now