android - Custom sync not working with Google Account (com.google) on some Samsung devices -
i implemented sync task same way basicsyncadapter example except google account in answer:
https://stackoverflow.com/a/2972918/2072569
it works on allmost devices except samsung sm-p600 (galaxy note 2014) android 4.4.2 , other samsung tablets.
my contentprovider in manifest file has label. cause of bug according this post @ android version of samsung tablets.
has samsung blocked adding sync tasks google account reason?
the sync added this:
removeallsynctasks(); contentresolver.setissyncable(maccount, content_authority, 1); contentresolver.setsyncautomatically(maccount, content_authority, true); contentresolver.addperiodicsync(maccount, content_authority, bundle.empty, sync_frequency);
manifest part:
<service android:name=".data.sync.syncservice" android:exported="true" android:process=":sync"> <intent-filter> <action android:name="android.content.syncadapter"/> </intent-filter> <meta-data android:name="android.content.syncadapter" android:resource="@xml/syncadapter" /> </service> <provider android:name=".data.provider.levenscontentprovider" android:authorities="@string/authority" android:label="@string/app_name_sync" android:exported="false" android:syncable="true" />
syncadapter xml:
<?xml version="1.0" encoding="utf-8"?> <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:contentauthority="@string/authority" android:accounttype="com.google" android:uservisible="true" android:supportsuploading="true" android:allowparallelsyncs="false" android:isalwayssyncable="true"/>
when manually start sync. syncservice not starting @ samsung tablets (it works on other devices).
it turns out had nothing samsung / os version...
the constructor of synchelper was:
public synchelper(context context, string accountname) { account account = null; account[] accounts = accountmanager.get(context).getaccounts(); (account acc : accounts) { if(acc.name.equals(accountname)){ account = acc; } } if(account == null){ throw new invalidparameterexception("account not found"); } init(context, account); }
this not check type of account. there account of type com.evernote in list , used sync , ofcourse won't work.
added solve it:
public synchelper(context context, string accountname) { account account = null; account[] accounts = accountmanager.get(context).getaccounts(); (account acc : accounts) { if(acc.name.equals(accountname) && acc.type.equals(account_type)){ account = acc; } } if(account == null){ throw new invalidparameterexception("account not found"); } init(context, account); }
now can start bumping head against wall... ;-)
Comments
Post a Comment