Search code examples
androidandroid-intentandroid-gallery

Select Image only from Gallery android


I am using the following code to open Gallery for image selection

private void galleryIntent() {
    Intent intent = new Intent(Intent.ACTION_PICK,
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_file)), SELECT_FILE);

All is working fine but for the first time it gives a popup with two options to select:

enter image description here

Can I make my app such that it always open Gallery Directly without any such popup?

Thanks


Solution

  • Every gallery app has its own package name which can differ from device to device. To do what you intend, you must know the package name of the gallery app. Some device may not even have a default gallery app.

    What you have done is the right way to go and the user can decide to set the gallery app as the default app. Unless for very important or specific reason, it is more reasonable to give the user the choice.

    Look at Launching Gallery in android phones