如何使用DriveApi.OnSyncFinishCallback(Android的播放谷歌服务) [英] How to use the DriveApi.OnSyncFinishCallback (Android's Google Play Services)

查看:270
本文介绍了如何使用DriveApi.OnSyncFinishCallback(Android的播放谷歌服务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而Android的开发者文档指出,你可以使用DriveApi.OnSyncFinishCallback来(presumably)在完成本地contet和你的谷歌账户的驱动器之间的同步处理。通常这种同步自动appens,由谷歌trasparently Play管理服务,但显然你可以强制用给某一调用的同步请求:

The Android's developer documentation states that you can use a DriveApi.OnSyncFinishCallback to (presumably) handle when a synchronization between your local contet and your google drive account is completed. Normally such synchronization appens automatically, trasparently managed by Google Play Services, but apparently you can force a sync request with a call to:

Drive.DriveApi.requestSync(mGoogleApiClient);

我说显然是因为这个函数的官方文档是非常差的,至少(<一个href=\"https://developer.android.com/reference/com/google/android/gms/drive/DriveApi.html#requestSync%28com.google.android.gms.common.api.GoogleApiClient%29\" rel=\"nofollow\">https://developer.android.com/reference/com/google/android/gms/drive/DriveApi.html#requestSync(com.google.android.gms.common.api.GoogleApiClient))

反正OnSyncFinishCallback可以用此code实例:

Anyway, a OnSyncFinishCallback can be instantiated with this code:

OnSyncFinishCallback myCallback = new OnSyncFinishCallback(){

    @Override
    public void onSyncFinish(com.google.android.gms.common.api.Status arg0) {
        // TODO Auto-generated method stub

    }

};

我的问题是在哪里,我怎么能注册此回调,以便在完成同步时,它会自动叫什么名字?所述requestSync调用返回一个PendingResult只具有一个setResultCallback(ResultCallback为arg0)方法,这是不能被用于OnSyncFinishCallback

My question is where and how can I register this callback so it will be called automatically when the sync is completed? The requestSync call returns a PendingResult that only have a setResultCallback(ResultCallback arg0) method, that can't be used for a OnSyncFinishCallback.

推荐答案

原来OnSyncFinishCallback从API和DriveAPI.requestSync()删除没有做什么它应该。幸运的是谷歌刚刚在6.1版引入了新的驱动器API为Android的谷歌播放服务,特别是完成事件,这使得正是OnSyncFinishCallback应该做的。这里更多的官方细节 https://developers.google.com/drive/android/completion

It turned out that OnSyncFinishCallback was removed from API and DriveAPI.requestSync() doesn't do what it's supposed to. Fortunately Google just introduced new Drive API for Android in version 6.1 of Google Play Services, in particular the Completion Events, that makes exactly what OnSyncFinishCallback was supposed to do. More official detail here https://developers.google.com/drive/android/completion

这篇关于如何使用DriveApi.OnSyncFinishCallback(Android的播放谷歌服务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆