0

I am trying to build a simple android app which takes photo from camera and shows it in an image view.

I am confused what MediaStore.Images.Media.EXTERNAL_CONTENT_URI mean and do

Here is the code:

Intent intent=new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 1);

Aditya
  • 325
  • 6
  • 19
  • see if this helps you https://stackoverflow.com/questions/30654774/android-is-external-content-uri-enough-for-a-photo-gallery – Don Ha Nov 22 '20 at 03:29
  • Sorry I couldn't understand that, it would be nice if you give the explanation and the relevant code as answer. – Aditya Nov 22 '20 at 16:38

1 Answers1

0

In android external storage not means external drive but anything external to application. Even "File Explorer" and "Gallery" seems to act as external for an application.

(MediaStore.Images.Media.EXTERNAL_CONTENT_URI), this will go to external storage like gallery and pick the image and return it in from of a Uri data.

Here is an example function to pick the image from the gallery:-

fetchImageButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent image = new Intent(Intent.ACTION_PICK);
        image.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(image,1000);
    }
});

This will simply make an intent whose job is to pick the content(Intent.ACTION_PICK), then using intent object we try to fetch the data(Uri) from the gallery and then start the activity passing intent "object" and "RequestCode".

Codemaker2015
  • 12,190
  • 6
  • 97
  • 81