pick image from android gallery

Hello. I’m searching a way to load image from android gallery.
I’m found that:

but it is just open gallery. After a little work I simple modified it:

 public void OpenAndroidGallery()
    {
        #region [ Intent intent = new Intent(); ]
        //instantiate the class Intent
        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        
             //instantiate the object Intent
             AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
        #endregion [ Intent intent = new Intent(); ]


        #region [ intent.setAction(Intent.ACTION_GET_CONTENT); ]
        //call setAction setting ACTION_SEND as parameter
        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_GET_CONTENT"));
        #endregion [ intent.setAction(Intent.ACTION_GET_CONTENT); ]


        #region [ intent.setData(Uri.parse("content://media/internal/images/media")); ]
        //instantiate the class Uri
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");

        //instantiate the object Uri with the parse of the url's file
        AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "content://media/internal/images/media");

        //call putExtra with the uri object of the file
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
        #endregion [ intent.setData(Uri.parse("content://media/internal/images/media")); ]
        
             //set the type of file
             intentObject.Call<AndroidJavaObject>("setType", "image/jpeg");

        #region [ startActivityForResult(intent , 1); ]
        //instantiate the class UnityPlayer
        AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

        //instantiate the object currentActivity
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
        
             //call the activity with our Intent
             currentActivity.Call("startActivity", intentObject);
        #endregion [ startActivityForResult(intent , 1); ]
    }

Now it open gallery and I can choose image. Look at the last region.
But how I can use it as a texture for example?
How catch uri of image?

I think I can use some of unity assets, but now I try to implement it without assets.
And I hope it would be interesting for other beginners.

That’s all you need :))
unimgpicker

For an ordinary Android App, the results would be returned via the onActivityResult() callback function. So your Activity needs to override that function. The best way to accomplish that is to write a Java Plugin. The PlugIn could for instance extend the UnityPlayerActivity, override onActivityResult(), obtain the uri and send it to your Unity Code. Instructions on how to do this can be found in the docs.

You could also move all your image loading code to Java, which would be a lot cleaner.