How do I make my app use the default "Gallery" to get the path of an image?

0

I've seen some apps that use the standard Android Gallery to grab images from a particular folder, how do I do that?

Is it possible for some Android to come without the Gallery app? Or does the person remove?

    
asked by anonymous 21.08.2014 / 07:25

1 answer

2

Responding in reverse:

  

Is it possible for some Android to come without the Gallery app? Or does the person remove?

Yes, it is. In custom rom it is possible to remove and in standard Android, since API 14 or 15, I do not remember exactly, one can go in Settings, Apps and disable an application. It does not remove from the phone, but is the same effect, the application is totally unavailable.

  

I've seen some apps that use the standard Android Gallery to grab images from a particular folder, how do I do that?

Cast an intent with the action ACTION_GET_CONTENT and treat the return on the onActivityResult:

static final int REQUEST_IMAGE_OPEN = 1;

public void selectImage() {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.setType("image/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    // Only the system receives the ACTION_OPEN_DOCUMENT, so no need to test.
    startActivityForResult(intent, REQUEST_IMAGE_OPEN);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_OPEN && resultCode == RESULT_OK) {
        Uri fullPhotoUri = data.getData();
        // Do work with full size photo saved at fullPhotoUri
        ...
    }
}

The code above came from the Android documentation itself.

    
22.08.2014 / 07:02