12

I am newbie in Android and I have a requirement for selecting files on devices below API level 19.

I have tried

private void chooseFile() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             intent.setType("application/pdf|file");
        } else {
             intent.setType("image/*|application/pdf");
        }
        startActivityForResult(intent, PICKFILE_REQUEST_CODE);
}

Now I do not want Google drive to appear as an option and I want file-manager as an option. I want to do this with intents.

Can any one suggest how can I achieve this?

Shashanth
  • 4,995
  • 7
  • 41
  • 51
Vivek Pratap Singh
  • 1,564
  • 16
  • 26

2 Answers2

20

Have you tried

intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
MSpeed
  • 8,153
  • 7
  • 49
  • 61
4
 Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
 //intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
 intent.setType("application/pdf");
 startActivityForResult(intent, PICKFILE_REQUEST_CODE);

This will work for me to avoid gdrive from chooser

Sumit Bandekar
  • 410
  • 5
  • 10