sync_extras_upload 的用途是什么?

发布于 2024-12-28 15:37:29 字数 75 浏览 3 评论 0原文

在 ContentResolver 类中,有几个用于同步适配器的常量。我想知道常量 SYNC_EXTRAS_UPLOAD 的用途是什么?

Within the ContentResolver class, there are several constants that are used for syncadpaters. I want to know what the constant SYNC_EXTRAS_UPLOAD is used for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难得心□动 2025-01-04 15:37:29

如果您检查 SyncManager.java 文件,您会发现以下注释:

如果 extras 中的 ContentResolver.SYNC_EXTRAS_UPLOAD 布尔值为
* true 然后启动同步,仅检查要发送的本地更改
* 到服务器,否则启动首先获取任何内容的同步
* 在将本地更改发送回服务器之前从服务器进行更改
* 服务器。

在同一个文件中,这是 scheduleLocalSync API 的实现。

public void scheduleLocalSync(Account account, String authority) {
    final Bundle extras = new Bundle();
    extras.putBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, true);
    scheduleSync(account, authority, extras, LOCAL_SYNC_DELAY,
            false /* onlyThoseWithUnkownSyncableState */);
}

您的同步适配器的 onPerformSync 方法接收这些额外内容作为参数之一

If you check in the SyncManager.java file you find this comment:

If the ContentResolver.SYNC_EXTRAS_UPLOAD boolean in extras is
* true then initiate a sync that just checks for local changes to send
* to the server, otherwise initiate a sync that first gets any
* changes from the server before sending local changes back to
* the server.

and from the same file this is the implementation of the scheduleLocalSync API

public void scheduleLocalSync(Account account, String authority) {
    final Bundle extras = new Bundle();
    extras.putBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, true);
    scheduleSync(account, authority, extras, LOCAL_SYNC_DELAY,
            false /* onlyThoseWithUnkownSyncableState */);
}

The method onPerformSyncof your syncadapter receives those extras as one of the paramters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文