的ContentProvider不会在数据和放大器出现;同步区 [英] ContentProvider won't show up in Data & Synchronization area
问题描述
我试图得到一个自定义的ContentProvider数据和放大器下展现出来;同步,和我遇到了一些问题。也就是说,它没有显示出来。
的具体内容:
我的AndroidManifest.xml中有提供者和服务:
<提供机器人:名称=BooksProvider
机器人:标签=CLIENTNAME书
机器人:当局=com.clientname.reader.books
机器人:启用=真
机器人:出口=真
机器人:可同步=真正的>
<授予-URI-许可安卓pathPattern = />中*。
< /供应商>
<服务机器人:名称=。sync.SyncService
机器人:出口=真正的机器人:工艺=:同步>
<意向滤光器>
<作用机器人:名称=android.content.SyncAdapter/>
&所述; /意图滤光器>
<元数据的android:NAME =android.content.SyncAdapater
机器人:资源=@ XML / syncadapter/>
< /服务>
和RES / XML / syncadapter.xml有以下几点:
< XML版本=1.0编码=UTF-8&GT?;
<同步适配器的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:contentAuthority =com.clientname.reader.books
机器人:accountType =com.google
机器人:supportsUploading =真
机器人:userVisible =真
/>
为了安全起见,我还叫上的onCreate如下:
的AccountManager的AccountManager = AccountManager.get(getApplicationContext());
帐户[]帐户= accountManager.getAccountsByType(com.google);
对于(账户账号:账号){
Log.d(TAG,账户:+ account.name);
ContentResolver.setIsSyncable(帐户,Reader.AUTHORITY,1);
}
当我加载的活动,我得到亚洲开发银行记录从ContentResolver.setIsSyncable说,帐户已被设置为可同步,所以这种方法没有做任何事情。
然而,供应商的拒绝可显示在设置>帐户与同步>数据和放大器;同步。为什么任何想法?任何人都知道它是如何确定的上的那款?
一些详细信息:
花费数小时调试完毕后,我来过这个错误:
10月4号至一十一号:46:02.370:DEBUG / SyncManager(105):找不到同步适配器SyncAdapterType键{名= com.clientname.reader.books,类型= com.google},因为它移除设置
这也似乎我SyncService类是从来没有真正得到调用。我是不是应该被调用它自己?没有样品的我见过,或在野外应用程序调用它自己,但他们也都具有权威性的组件。思考?
<元数据的android:NAME =android.content.SyncAdapater
机器人:资源=@ XML / syncadapter/>
没有任何人注意到答案?
天哪,我讨厌白痴。
I'm trying to get a custom ContentProvider to show up under Data & synchronization, and I'm running into some problems. Namely, it's not showing up.
The specifics:
My AndroidManifest.xml has the provider and service:
<provider android:name="BooksProvider"
android:label="ClientName Books"
android:authorities="com.clientname.reader.books"
android:enabled="true"
android:exported="true"
android:syncable="true">
<grant-uri-permission android:pathPattern=".*" />
</provider>
<service android:name=".sync.SyncService"
android:exported="true" android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data android:name="android.content.SyncAdapater"
android:resource="@xml/syncadapter" />
</service>
And res/xml/syncadapter.xml has the following:
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.clientname.reader.books"
android:accountType="com.google"
android:supportsUploading="true"
android:userVisible="true"
/>
Just to be safe, I've even called the following on onCreate:
AccountManager accountManager = AccountManager.get(getApplicationContext());
Account[] accounts = accountManager.getAccountsByType("com.google");
for(Account account : accounts){
Log.d(TAG, "Account: " + account.name);
ContentResolver.setIsSyncable(account, Reader.AUTHORITY, 1);
}
When I load up the Activity, I get adb logging from ContentResolver.setIsSyncable saying that account is already set to be syncable, so the method isn't doing anything.
And yet, the provider refuses to show up in Settings > Accounts & Sync > Data & synchronization. Any ideas on why? Anyone know how it's determined what appears in that section?
[edit] Some more information:
After spending hours debugging, I'm coming across this error:
04-11 10:46:02.370: DEBUG/SyncManager(105): can't find a sync adapter for SyncAdapterType Key {name=com.clientname.reader.books, type=com.google}, removing settings for it
It also appears my SyncService class is never actually getting called. Am I supposed to be invoking it myself? None of the samples I've seen or applications in the wild invoke it themselves, but they also all have auth components. Thoughts?
<meta-data android:name="android.content.SyncAdapater"
android:resource="@xml/syncadapter" />
Does anyone else notice the answer?
God, I hate being an idiot.
这篇关于的ContentProvider不会在数据和放大器出现;同步区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!