读取内容提供商标签时出错
因此,我尝试基于内容提供商和服务器的 SyncAdapter 实现同步。似乎一切都已创建并初始化良好,我可以在“帐户和同步”中看到我的帐户,还可以看到用于同步我的内容提供商的复选框。
但我在 LogCat 中遇到了奇怪的错误:
ERROR/AccountSettings(130): Provider need a label for Authority 'com.opussync.model.db.opuscontentprovider'
但我已经在清单中设置了该标签!
这就是为什么我认为当我尝试检查帐户数据和同步中的同步复选框时,我会收到一条消息:
同步当前遇到问题。它很快就会回来
这是我的清单的主要部分:
<!-- CONTENT PROVIDER -->
<provider
android:name=".model.db.OpusContentProvider"
android:label="BLABLABLA"
android:authorities=".model.db.opuscontentprovider"
></provider>
<!-- SERVICES -->
<service android:name=".service.OpusAccountsSyncService" android:exported="true" android:process=":zencoosync">
<intent-filter >
<action android:name = "android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name=".model.syncadapter.SyncService"
android:exported="true"
android:syncable="true"
>
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
So, I trying to implement synchronization based on SyncAdapter of my content provider and server. Seems everything created and initializated well and I can see my account in Accounts&Sync and also see checkbox for sync my content provider.
But I got strange error in LogCat:
ERROR/AccountSettings(130): Provider needs a label for authority 'com.opussync.model.db.opuscontentprovider'
But I has set that label in manifest for sure!
And that's why I think when I try to check sync checkbox in Data&Synchronization of my account I get a message:
Sync is currently experiencing problems. It will be back shortly
Here is main parts of my manifest:
<!-- CONTENT PROVIDER -->
<provider
android:name=".model.db.OpusContentProvider"
android:label="BLABLABLA"
android:authorities=".model.db.opuscontentprovider"
></provider>
<!-- SERVICES -->
<service android:name=".service.OpusAccountsSyncService" android:exported="true" android:process=":zencoosync">
<intent-filter >
<action android:name = "android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name=".model.syncadapter.SyncService"
android:exported="true"
android:syncable="true"
>
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
包名称不会自动添加到
android:authorities
中。因此,请将
android:authorities=".model.db.opuscontentprovider"
更改为android:authorities="com.opussync.model.db.opuscontentprovider"
或content://.model.db.opuscontentprovider
作为代码中内容提供程序的基本 URL。Package name is not automatically added to
android:authorities
.So, either
android:authorities=".model.db.opuscontentprovider"
toandroid:authorities="com.opussync.model.db.opuscontentprovider"
orcontent://.model.db.opuscontentprovider
as the base URL for content provider in code.