Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ContentProvider won't show up in Data & Synchronization area

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?

like image 897
Paddy Avatar asked Apr 11 '11 09:04

Paddy


People also ask

How do I retrieve data from my content provider?

To retrieve data from a provider, your application needs "read access permission" for the provider. You can't request this permission at run-time; instead, you have to specify that you need this permission in your manifest, using the <uses-permission> element and the exact permission name defined by the provider.

How exploitable is content provider?

According to the question, A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the Content Resolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.

How can I access my content provider from another application?

To access the data from a content provider, URI is used as a query string. Details of different parts of Content URI: content:// – Mandatory part of the URI as it represents that the given URI is a Content URI. authority – Signifies the name of the content provider like contacts, browser, etc.

Which of the following is used to identify data in a content provider?

Accessing Data with Content Provider We need to use the ContentResolver object in our application, in order to communicate with the content providers for data access. Now to enable communication between the user interface and ContentResolver, we use another object, CursorLoader to run query asynchronously.


1 Answers

<meta-data android:name="android.content.SyncAdapater"
     android:resource="@xml/syncadapter" />

Does anyone else notice the answer?

God, I hate being an idiot.

like image 155
Paddy Avatar answered Oct 30 '22 15:10

Paddy