How to store a bitmap as a texture from android

Hello guys,

I was trying to achieve the following -

Open the android gallery and save the image picked as a texture for the project.

I am a learner with C++, well programming in general, but I am able to achieve opening the gallery in android through content provider. Now, what I want is to save that image in unreal as a texture. I cannot achieve that, here is the android part of the code that I added.

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

And the onActivityResult part -

    try { 
                // When an Image is picked
                if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK && null != data) {
                    // Get the Image from data
                    Uri selectedImage = data.getData();
                    String[] filePathColumn = { MediaStore.Images.Media.DATA };
     
                    // Get the cursor
                    Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
                    // Move to first row
                    cursor.moveToFirst();
     
                    int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                    imgDecodableString = cursor.getString(columnIndex);
                    cursor.close();
                    Bitmap bitmap=BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage));
     
                } else {
                    Toast.makeText(this, "You haven't picked Image",
                            Toast.LENGTH_LONG).show();
                }
            } catch (Exception e) {
                Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG)
                        .show();
            }

This is how I’m calling from C++ (Generic call like in AndroidJNI), I’m sure here is where I am supposed to store it in a UTexture2D type variable but I don’t know how

FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GameActivityThis, FJavaWrapper::AndroidThunkJava_OpenGallery);

And then implementing this so that I can use it in blueprints. So, can someone help me ?

Have you tried to use images in power of two format?