The google file modification date gave the wrong time

I am trying to create an Android application that uses a Google drive to store a file. Now I want to detect changes in one file by any device. To detect a change in the file, try to get the modified file time using the code below (using the new google drive api for android) https://developers.google.com/drive/android/get-started

DriveFile file = Drive.DriveApi.getFile(mGoogleApiClient, fileId);
Metadata fmd = file.getMetadata(mGoogleApiClient).await().getMetadata();
Log.e("modified date",""+fmd.getModifiedDate()); 

but his time indicating the time is not always wrong. it does not return the modified time when another device (using the same application) modifies the same file. is there any other way to detect changes in the file ??? thanks

I also use the code below, but no luck

DriveFile file = Drive.DriveApi.getFile(mGoogleApiClient, fileId);
file.getMetadata(mGoogleApiClient).addResultCallback(new DemoClassForHandleCallBack());

public class DemoClassForHandleCallBack implements OnMetadataRetrievedCallback{

    @Override
    public void onMetadataRetrieved(MetadataResult result) {
        boolean isSuccess = result.getStatus().isSuccess();
            Log.i("is success",""+isSuccess);
        Metadata fmd = result.getMetadata();
        Log.e("modified date",""+fmd.getModifiedDate());
        }
    }
+4
3

, , .

, /, , .

, :

DriveFile file;

// Trick Google Drive into fetching the remote file
// which has the latest metadata
file.open( getGoogleApiClient(), DriveFile.MODE_READ_ONLY, null).await();

DriveResource.MetadataResult result = file.getMetadata(getGoogleApiClient()).await();
Metadata metadata = result.getMetadata();

// Get the modified date
metadata.getModifiedDate();

, - .

+2

. etag.

0

API onMetadataRetrieved(MetadataResult result)? . getMetaData() onMetadaRetrieved.

0

Source: https://habr.com/ru/post/1527084/


All Articles