Open the Android Photo Gallery and get photo

Hi guys

How can i get a photo from Android Device.

i want to open Android Gallery of photos and pick one and send back to my game.

i saw that post How to access iOS photo library / use Objective-C properly? - UE4 AnswerHub

but i’m a newbie on c++ until now i dont know how to convert that code to work on Android

plz help

Hi ArkanSephin,

This involves adding code on the Java side to trigger the intent like this:

	public void AndroidThunkJava_OpenGallery()
             Intent Intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
             startActivityForResult(galleryIntent, RESULT_LOAD_IMG);

You would add this to and add C++ calling in AndroidJNI.h and AndroidJNI.cpp to this method. To get the picked image you’d need to check in onActivityResult() for requestCode == RESULT_LOAD_IMG, resultCode == RESULT_OK, and data != null. The data then would need to be resolved to get access to the image and fed back to C++ depending on what you wanted to do with it.

Hm… i’ll try
i’m newbie on c++ but i think i can do
thx for replay

Hey I am trying to do the same thing and I was wondering if anyone has successfully implemented this since this was first posted? As a fellow newbie to c++ and Android development, I found this article helpful for understanding Android Intents:

From what I understand, developing for Android requires Java. When developing through Unreal, do we ever need to touch Java, or does the c++ compile into/call the necessary Java code?

Wish this was a built in blueprint function of the engine as would love to do something similar as well…

or just basic file rename delete in the internal project directory. We can currently open and save such as .png files saved after photo function. But you could never delete them or rename from a blueprint project(on mobile) Rama makes a great plugin for windows.