Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Picker for Google Drive Rest API for Android

While the Google Drive Android API, an API separate from the Google Drive Rest API, does contain a file picker, the Google Drive Android API is not integrated with all the features of the Google Drive Rest API, such as exporting Google Docs files to a different format. Although there is a Google Drive Rest API file picker available for web applications, I have not found one for Android applications. Does anyone know the best way to create a file picker for the user to choose files from their Google Drive account by using the Google Drive Rest API?

like image 608
Daniel Avatar asked Jul 18 '16 20:07

Daniel


People also ask

How do I enable Google picker API?

Enable the Google Picker API If you haven't done so already, create your application's API key by clicking Create credentials > API key. Next, look for your API key in the API keys section. If you haven't done so already, create your OAuth 2.0 credentials by clicking Create credentials > OAuth client ID.

Is there an API for Google Drive?

The Google Drive API allows you to create apps that leverage Google Drive cloud storage. You can develop applications that integrate with Drive, and create robust functionality in your application using the Drive API.

What is file picker on Google Docs?

The Google Picker is a "File Open" dialog for information stored on Google servers. You can use the Google Picker API to allow users to open or upload Google Drive files.

How do I automatically download files from Google Drive?

Open Chrome. Settings. Click Advanced and go to Downloads. Click Change and in the pop-up, navigate to the Downloads folder that you dragged to your Google Drive folder and click Select.


1 Answers

The file picker is implemented as an Intent and allows you develop a native Android user experience with just a couple lines of code. This following code snippet launches the picker and allows the user to select a text file:

// Launch user interface and allow user to select file
IntentSender i = Drive.DriveApi
.newOpenFileActivityBuilder()
.setMimeType(new String[] { “text/plain” })
.build(mGoogleApiClient);
startIntentSenderForResult(i, REQ_CODE_OPEN, null, 0, 0, 0);

The result is provided in the onActivityResult callback as usual.

You may be wondering how the Google Drive Android API relates to the Storage Access Framework.

The Storage Access Framework is a generic client API that works with multiple storage providers, including cloud-based and local file systems. While apps can use files stored on Google Drive using this generic framework, the Google Drive API offers specialized functionality for interacting with files stored on Google Drive — including access to metadata and sharing features. Additionally, as part of Google Play services the Google Drive APIs are supported on devices running Android 2.3 Gingerbread and above.

like image 175
Android Enthusiast Avatar answered Sep 21 '22 08:09

Android Enthusiast