How to select files from google drive in android?

↘锁芯ラ 提交于 2020-01-01 09:42:56

问题


Is there any way to start file picker for google drive in android app - to do something similar to this http://googleappsdeveloper.blogspot.com/2012/08/allowing-user-to-select-google-drive.html. I need to allow user to select files from google drive, so I can use their bytes in my application. Thanks.


回答1:


Yes, there is a file picker in the GDAA. The best place to see it's use is this demo, specifically the Intents section.

There are 2 methods in the demo you are interested in:

  1. the 'Pick a file with opener activity' ,
  2. and the 'Pick a folder with opener activity'

but they are essentially the same, differing only in the MIME TYPE filter specified here:

IntentSender intentSender = Drive.DriveApi.newOpenFileActivityBuilder()
 .setMimeType(new String[] { DriveFolder.MIME_TYPE })  // <--- FOLDER
 //.setMimeType(new String[] { "text/plain", "text/html" }) // <- TEXT FILES
 .build(getGoogleApiClient());

Good Luck




回答2:


There is an api for this. I think this google's documentation should help https://developers.google.com/drive/android/queries. I'm not sure on how you want to go about it.



来源:https://stackoverflow.com/questions/18188653/how-to-select-files-from-google-drive-in-android

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