Jump to content

So Hi guys. I'm looking to get the full image path and not what is being returned which I think is the thumbnail of the image. This is what I have so far.

 

//This gets called from a button click and opens the image selector.


Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);intent.addCategory(Intent.CATEGORY_OPENABLE);intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);intent.setType("image/jpeg");startActivityForResult(intent, SELECT_PICTURE);
	

 

And this from the Activity's onActivityResult which gets the data from the image selector(intent).


protected void onActivityResult(int requestCode, int resultCode, Intent data) {if (resultCode == RESULT_OK && requestCode == SELECT_PICTURE) {    if (data.getData() != null) {        //If uploaded with Android Gallery (max 1 image)        Uri selectedImage = data.getData();        String rp = FileUtility.getRealPathFromURI(this,selectedImage);        File tempFile = new File(rp);        uris.add(Uri.fromFile(tempFile));    }}
	

 

now selectedImage will get set to something like "content://com.android.providers.media.documents/document/image%3A35899"

which is not what I want. So I try and get the real path which makes rp = "/storage/emulated/0/DCIM/100MEDIA/IMAG0144.jpg". Lastly I convert the string to a File so I can convert back to URI and then add that to a collection(not important). But yeah the URI ends up being what rp equaled which is "/storage/emulated/0/DCIM/100MEDIA/IMAG0144.jpg" I know this is the wrong file because I took the photo and set its name and location and it's definitely not that.

 

 

 

 

 

 

Link to comment
https://linustechtips.com/topic/787521-android-select-image/
Share on other sites

Link to post
Share on other sites

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

×