How to restrict Google drive option from not appearing while selecting file or image in Android below API level 19?

谁说我不能喝 提交于 2020-01-02 02:24:07

问题


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?


回答1:


Have you tried

intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);



回答2:


 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



来源:https://stackoverflow.com/questions/34310167/how-to-restrict-google-drive-option-from-not-appearing-while-selecting-file-or-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!