简体   繁体   中英

Listen to changes of a file in cloud

once i gained persistant access to a file in a cloud picked by the user using

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
intent.setType("application/json");
startActivityForResult(intent, IMPORT);

and

getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

is there a way to listen to changes made to that file outside the app? Or would i have to check it myself with some time interval? If so, can i get the last modified date without downloading the whole file?

is there a way to listen to changes made to that file outside the app?

No, sorry.

Or would i have to check it myself with some time interval?

Presumably yes.

If so, can i get the last modified date without downloading the whole file?

Wrap the document Uri in DocumentFile.fromSingleUri() , then call lastModified() on the DocumentFile . Note that the value of this is up to the cloud document provider and may or may not be up to date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM