I am trying to open a file from Google Drive in my android app. Here is what I currently have.
Intent importIntent = new Intent(Intent.ACTION_GET_CONTENT);
importIntent.setType("file/*");
startActivityForResult(importIntent, ACTIVITY_REQUEST_CODE_IMPORT);
This opens a "Open From" dialog which allows to select files using Google Drive, Downloads and my file browser. I can select files using my file browser without a problem. But Google Drive doesn't allow me to select files. All files shown in Google Drive are grayed out and not selectable. Same happens when I try to select using Downloads.
How can I resolve this? if I use importIntent.setType("*/*"), Google Drive allows to select files, but several other options including Contacts, Images appear in "Open From" dialog which I do not want.
Thanks
You have to set a more specific MIME type or a list of them, but you have to keep in mind that the ACTION_GET_CONTENT intent won't work with the latest Google Drive version starting from Android Kitkat. In order to get files from Drive you have to use the Google Drive API or use the storage access framework (SAF). Using SAF however it could be not what you want because it allows the user select other sources and not only Drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With