How to use the DriveApi.OnSyncFinishCallback (Android's Google Play Services) -
the android's developer documentation states can use driveapi.onsyncfinishcallback (presumably) handle when synchronization between local contet , google drive account completed. such synchronization appens automatically, trasparently managed google play services, apparently can force sync request call to:
drive.driveapi.requestsync(mgoogleapiclient);
i "apparently" because official documentation of function poor, @ least (https://developer.android.com/reference/com/google/android/gms/drive/driveapi.html#requestsync(com.google.android.gms.common.api.googleapiclient))
anyway, onsyncfinishcallback can instantiated code:
onsyncfinishcallback mycallback = new onsyncfinishcallback(){ @override public void onsyncfinish(com.google.android.gms.common.api.status arg0) { // todo auto-generated method stub } };
my question , how can register callback called automatically when sync completed? requestsync call returns pendingresult have setresultcallback(resultcallback arg0) method, can't used onsyncfinishcallback.
i must requestsync working absolutely fine me (january 2015, google play services 6.5.87). backup of database on 1 device , restore on device, before restore call requestsync way:
drive.driveapi.requestsync(mgoogleapiclient) .setresultcallback(new resultcallback<status>() { @override public void onresult(status result) { if (!result.issuccess()) { // sync not ok showmessage("sync error"); return; } // sync ok. can safely query // database file , restore it. ...
by way, i'm using root folder, not appfolder. appfolder might have additional synchronization issues when installing/uninstalling app different devices, moment prefer stick root folder.
Comments
Post a Comment