使用 SyncAdapter 与 *local* gmail 和 facebook 应用程序数据同步 [英] Use SyncAdapter to sync with *local* gmail and facebook app data

查看:25
本文介绍了使用 SyncAdapter 与 *local* gmail 和 facebook 应用程序数据同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我需要开发的应用程序,我需要能够使用 SyncAdapter 与 gmail 和 facebook 数据同步.我希望与本地 facebook 和 gmail 应用程序(如果可用)而不是他们的远程服务器同步.与本地应用同步意味着更少的电池使用、更少的网络使用、更快的同步等.当然,如果需要,我会设置正确的权限.

For an app I need to develop, I need to be able to sync with both gmail and facebook data using a SyncAdapter. I'm hoping to sync with the local facebook and gmail apps (if available) instead their remote servers. Syncing with the local apps would mean less battery usage, less network usage, faster syncing, etc. Of course, if needed, I will set the correct permissions.

我的问题:

  • 如果有任何应用程序(gmail/facebook)可用,是否可以查询它们的数据(消息、事件等)?
  • 如果没有,是否可以从他们那里获取身份验证令牌(或任何类型的凭据),这样我就可以在无需用户再次输入每个用户名和密码的情况下查询服务器?
  • 如果可能的话,是否也可以在 facebook 或 gmail 应用程序同步后立即自动同步,以便我在他们完成后立即获得新数据?

如果这些都不可用,我想我需要自己获取数据,所以这与这个问题无关.

If none of these are available, I guess I'll need to fetch the data myself, so that's not relevant for this question.

推荐答案

我不能代表 Facebook,但 GMail 应用程序不允许这样做.它以前可以工作,但他们已经保护了它,以便只有 Google 应用程序可以查询电子邮件内容提供商.您可以做的最好的事情是使用 获取消息数量标签 API.您可以使用标准 Android AccountManager 获取 Google 服务的身份验证令牌(ClientLogin 或 OAuth2).然后,您必须使用它连接到特定的 API 以获取实际数据.

I can't speak for Facebook, but the GMail app doesn't allow this. It used to work previously, but they have since secured it so that only Google apps can query the email content provider. The best you can do is get the number of messages with the labels API. You can get an authentication token (ClientLogin or OAuth2) for Google services using the standard Android AccountManager. You will then have to use it to connect to the particular API to get the actual data.

这篇关于使用 SyncAdapter 与 *local* gmail 和 facebook 应用程序数据同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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