无帐户同步适配器 [英] Sync Adapter without Account

查看:29
本文介绍了无帐户同步适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过云从我的应用中获取一些数据.我在 RESTful android 应用程序上观看了谷歌 IO 视频@http://www.youtube.com/watch?v=xHXn3Kg2IQE&t=43m58s 建议在最后的幻灯片中使用 SyncAdapter 与 Android 系统集成.

I need to fetch some data over the cloud from my app. I've watched the google IO video on RESTful android apps @ http://www.youtube.com/watch?v=xHXn3Kg2IQE&t=43m58s It recommends in the final slides to use a SyncAdapter to integrate with the Android System.

后来才知道,要实现SyncAdapter,得用一个Account.我的应用程序不使用帐户.用户无需注册即可自由下载数据.我还可以使用 SyncAdapter 吗?有我可以使用的股票虚拟账户吗?

Later I learned that one has to use an Account to implement SyncAdapter. My app does not use an account. Users can freely download data without registration. Can I still use SyncAdapter? Is there a stock dummy account that I could use?

我的应用程序有一个内容提供程序,所以这不是问题

I do have a content provider for my app so that's not a problem

Edit2:我刚刚查看了设置"->帐户和"下的天气"和股票"应用程序同步.您可以看到它们允许同步,但没有删除帐户按钮.另一方面,谷歌、Facebook 和 Skype 应用程序允许同步加上他们有一个删除帐户按钮.这意味着 Weather 和 Stock 不使用帐户,而 Google、Facebook 和 Skype 使用.

I've just looked at the Weather and Stock apps under Settings -> Accounts & Sync. You can see that they allow syncing, but don't have a remove account button. On the other hand, Google, Facebook and Skype apps allow syncing PLUS they have a remove account button. This means Weather and Stock don't use accounts, whereas Google, Facebook and Skype do.

我找到的教程@http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/ 和@ http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/ 说必须有一个帐户才能使用同步适配器.:S ???

The tutorials I found @ http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/ and @ http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/ say that one MUST have an account to use Sync Adapter. :S ???

推荐答案

我创建了一个联系人同步适配器,但我没有帐户授权和/或配置屏幕.没那么难.我不认为必须处理 Android 帐户的问题.

I have created a contact sync adapter where I don't have a account authorization and or configuration screens. It wasn't that hard. I don't think having to deal with the Android Account stuff was that much of a deal.

引用您的教程链接:

坏消息是没有库存"功能为您提供向用户提供帐户的简单方法系统.但是,在同一个 Sync随附的适配器示例SDK有很多代码可以借给你账号功能.除非你想要一个自定义凭据屏幕,您可以窃取所有代码com.example.android.samplesync.authenticator只做了一些小改动的包.

The bad news is that there is no "stock" functionality to give you an easy way to provide an Account to the system. However, in the same Sync Adapter Example that comes with the SDK there is a lot of code you can borrow to give you Account functionality. Unless you desire a custom credentials screen, you can heist all the code in the com.example.android.samplesync.authenticator package with only a few minor changes.

所以它基本上只是示例中的复制和粘贴,这几乎就是我所做的并且效果很好.

So it's basically just a copy and paste from the example, that's pretty much what I did and it worked fine.

我不确定,但所有没有删除帐户"的适配器似乎都是我看过的所有设备上的内置 ROM 适配器.我不确定你是否需要担心.

I don't know for sure but all the adapters that don't have "Remove Account" seems to be built-in ROM adapters on all the devices I've looked at. I'm not sure you have to worried about it.

这篇关于无帐户同步适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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