Android – use Google drive API for Android

For my application, I need to synchronize the list with Google cloud hard disk. I have implemented signin and let my main_ Activity implements two:

com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks,
com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener

Even if I read the entire Google drive API for Android document, more specifically the store application data part. After reading the example on GitHub, I can't make it work. Personally, I think this document is really confusing. It's unclear what's the difference between Google drive API for Android and Google drive rest API, and which one I should use for my scenario

In addition, I noticed that the example on GitHub extends a custom activity, including other methods

Can you step by step explain how to use the Android driver API?

resolvent:

I am familiar with your frustration. There are "Google drive Android API" (GDAA) and "drive rest API". There are some good documents on the Internet, but finding it and understanding it can be a challenge, especially because the package names are very similar. In addition, there are at least two existing versions of "drive rest API", and you must keep the version direct

About GDAA, you have found this document, but you should take a closer look. I suggest you do a simple activity, such as creating a file, and then start working from there

I think the custom activity in the GitHub example you referenced is basedemoactivity. This class only provides some life cycle methods and some other common routines

Google drive Android API (GDAA) is closely integrated with play service, and Google claims to provide better performance. (see note here):

However, due to the increasingly strict restrictions on synchronization frequency, I have abandoned GDAA in most cases. (for more details, see the notes at the bottom of this article.)

A key thing to remember when using GDAA is that even if your code can run on the UI thread, GDAA cannot because it represents a potentially lengthy task you perform. This means that once you request GDAA to complete a task from the UI thread, GDAA will perform the work in the background (not on the UI thread) and pass the result to you through a callback

Although this is necessary, this structure means that your code will be a series of methods called by GDAA and will not necessarily show the clear sequential format you may be used to. I think it is the Pachinko machine in software

It's not a step - by - step explanation, but I hope it will help point you in the right direction

About the synchronization frequency: more specifically, the upload to the server will be carried out according to the provisions of drivepreferences API. The upload usually occurs quickly. However, the download rate is limited. See this document

I think the "backoff duration" depends on the version of play service installed. In my experience, this period of time ranges from a few minutes to half an hour or more. This may have changed. I tried to find the documentation on this, but failed

If the download restrictions of GDAA are not suitable for you, you may need to consider drive rest. You can also consider firebase as a possible solution

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>