简体   繁体   中英

Android : Drive app and Intent.ACTION_GET_CONTENT

I would like to import files from Installed Google Drive App to my app using the Intent.ACTION_GET_CONTENT and the mimetype of the intent set to "*/*".

I am able to do this with other installed app like Dropbox,Onedrive and box, but not with Google Drive. Here is my code :

Intent action = new Intent(Intent.ACTION_GET_CONTENT);          
            action.putExtra(Intent.EXTRA_LOCAL_ONLY, true);         
action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(Intent.createChooser(action, "Upload file from..."),Constants.FILE_CHOOSER_REQUEST_CODE );

Thanks.

Very late answer but you need to remove action.putExtra(Intent.EXTRA_LOCAL_ONLY, true); in order to see Google Drive option in the picker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM