androidandroid-intentandroid-intent-chooser

How to get first two chooser intents and display only them for user in android


I'm trying to display only gallery and File manager in the chooser intent

So, i tried something like below

Intent intent = new Intent();
                intent.setType("image/*");
                intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                intent.putExtra(Intent.EXTRA_LOCAL_ONLY,true);
                intent.setAction(Intent.ACTION_PICK);
                startActivityForResult(Intent.createChooser(intent, "Select Picture"), RESULT_LOAD_IMAGE);

But along with gallery and File Explorer it is showing other apps too. It is also showing google drive

So, i decided to choose only first two intents and remove others.

How to achieve this ?


Solution

  • For your case the easiest way to achieve what you need is

    to add below line

    intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    

    By adding above line you can get rid of installed apps by user. but be aware of one thing

    Don't go for first two chooser intents it is not recommended and I don't know the reason, Also I don't know how to do that.

    Hope, This gives a proper explanation with answer.