Android API for Google Drive

Google Drive API Not Available

Google Drive SDK is deprecated. In order to use the Google Drive SDK you need to use drive REST APIs.

From the documentation:

This API is deprecated. Clients must migrate to the Drive REST API or another suitable solution to avoid disruptions to your application.

Android - Using the Google Drive API for android

I am familiar with your frustration. There is the "Google Drive Android API" (GDAA) and the "Drive REST API." There is some good documentation on the web, but finding it and making sense of it can be a challenge, especially since the names of the packages are so similar. In addition, there are at least two extant versions of "Drive REST API" and you have to keep the versions straight.

Regarding GDAA, you have already found this documentation, but you should take a closer look. I suggest that you do a simple activity such as creating a file and work from there.

I think that the custom Activity in the example on GitHub that you reference is the BaseDemoActivity. That class simply provides some of the life cycle methods and some other common routines.

The Google Drive Android API (GDAA) is tightly integrated with Play Services and Google claims offers better performance. (See the note here):

Note: This quickstart illustrates the use of the Drive REST API in an Android application. However, in the majority of cases production Drive apps will strongly benefit by making use of the Drive API for Android, which is integrated with Google Play Services and offers better performance. Before using the Drive REST API in your Android application, you should carefully review the Drive API for Android and use it in your application if possible. A Drive API for Android Quickstart is available if you want to learn more.

Even though, I have abandoned GDAA in most instances due to tightening restrictions on the frequency of syncing. (For more detail, see the notes at the bottom of this post.)

When working with GDAA, one key thing to keep in mind is that even though your code can run on the UI thread, GDAA cannot due to potentially lengthy tasks that it performs on your behalf. That implies that once you request GDAA to accomplish some task from the UI thread, GDAA will do that work in the background (not on the UI thread) and deliver results to you through the callbacks.

This structure, although necessary, means that your code will be a series of methods that are invoked by GDAA and will not necessarily demonstrate a clear sequential format that you may be used to. I think of it as a Pachinko machine in software.

Although not a step-by-step set of instructions, I hope this helps point you in the right direction.


Regarding Sync Frequency:
More specifically, uploads to the server will occur as specified with DrivePreferencesApi. Uploads usually happens fairly quickly. Downloads, however, are rate limited. See this documentation.

In order to avoid excessive load on the device and the server, sync requests are rate limited. In this case, the operation will fail with DRIVE_RATE_LIMIT_EXCEEDED status, which indicates that a sync already happened quite recently so there is no need for another sync. The operation will succeed when reattempted after a sufficient backoff duration.

I believe that the "backoff duration" is dependent upon the version of Play Services installed. In my experience, this duration varied from a couple of minutes to 1/2 hour or more. This may have changed and I tried to find documentation on this but was unsuccessful.

If the download limitation of GDAA doesn't work for you, then you may want to consider Drive REST. You can also look into Firebase as a possible solution.

Android API for Google Drive?

edit: with the deprecation of the docs list API, this is no longer the best solution

You can use the existing Documents List API to access Drive resources, they share the same endpoints.

Is there a GOOGLE DOCS API for Android

No, there is no Android library for Google Docs API.

But, there is a Java client for Docs API, which you can use in Android. Here's the official guide: https://developers.google.com/docs/api/quickstart/java

For your second question: Drive API for Android is now deprecated (given here), so it's best to switch to Docs REST API. Of course, you can use its Android client to avoid making direct/raw HTTP requests (as I mentioned above).

Android App with Google Drive API stucks after choosing an account. Why?

I just solved it. For all those who encounter this problem: from the Google API console, remove the consent screen from the test state and publish it.

Using Google Drive API with One-Tap Sign-In on Android

One-Tab is a service oriented towards account creation and login. As described by the overview docs:

With just one tap, they (users) get a secure, token-based, passwordless account with your service, protected by their Google Accoun

On the other hand, if you want to interact with the APIs as an user, then you would need to use an OAuth 2.0. approach in order to handle the authentication flow. This service is independent of One-Tap, so you need different tokens per each. If you need to work with the Drive API, you can follow this quickstart to develop a working OAuth 2.0 token flow.

Android Google Drive Api share files across devices and accounts

For everyone who is interested in a solution:

  • I found no way to sync shared files with the google android native API. (besides the file picker)
  • In case you want to do so you have to use the google drive rest API.

A little advantage for this solution. I think the java rest API is anyway much more suited for this kind of work. Code gets in that way much more readable.



Related Topics



Leave a reply



Submit