android-syncadapter

How to post a message from a background service to a UI fragment?

本秂侑毒 提交于 2019-12-05 13:53:27
I have an issue with EventBus from Greenrobot. I was trying to post an event from a background service form my sync adapter and catch it in a fragment to update the UI. The problem is that when I try to post the event from sync adapter I have get the following in the debug log: No subscribers registered for event class olexiimuraviov.ua.simplerssreader.event.UpdateUIEvent No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent I register fragment in onResume and unregister it in onPause @Override public void onResume() { super.onResume(); EventBus.getDefault()

data & synchronization - manually sync mail. calender and contacts

≯℡__Kan透↙ 提交于 2019-12-05 09:52:36
I am trying to write an app that syncs my mail and my calender with just a single click. After looking through this forum I found some good hints and wrote a short test app that takes my first google account and starts syncing. The code is working so far but currently only the contacts were synced! AccountManager am = AccountManager.get(this); Account[] acc = am.getAccountsByType("com.google"); Account account = null; if (acc.length > 0) { account = acc[0]; Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); extras.putBoolean(ContentResolver.SYNC

What are Android SyncAdapter contentAuthority and accountType?

余生长醉 提交于 2019-12-05 08:15:50
I'm creating a custom Android SyncAdapter and hit a snag following the SDK example "SampleSyncAdapter". - I'm creating my equivalent of the xml/syncadapter.xml . Here's the parts I'm confused about: android:contentAuthority="com.android.contacts" android:accountType="com.example.android.samplesync" The documentation of AbstractThreadedSyncAdapter states: The android:contentAuthority and android:accountType attributes indicate which content authority and for which account types this sync adapter serves. The documentation is circular in that it says nothing the name doesn't already tell you. I

Using ContentResolver instead of ContentProviderClient in SyncAdapter

让人想犯罪 __ 提交于 2019-12-05 06:29:23
As I understand from the docs, one SyncAdapter defined in a SyncService is limited to receive only one ContentProvider authority to work on. But, at the same time, it has access to ContentResolver which it allows to run queries on other ContentProviders as well. I don't understand this particular design concept if a developer is needed to provide a single content authority to SyncAdapter and nonetheless she is able to do whatever she wants on whatever ContentProvider she has access to. My question is: What are the consequences of ignoring onPerformSync's parameters: String authority and

IllegalArgumentException: addAccount not supported

自作多情 提交于 2019-12-05 04:59:09
I followed this description to add my sync adapter. But there is a litte bug :-( When I open Settings -> Account -> Add account and select my account I get this error message java.lang.IllegalArgumentException: addAccount not supported at android.accounts.AccountManager.convertErrorToException(AccountManager.java:2147) at android.accounts.AccountManager.-wrap0(AccountManager.java) at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1993) at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69) at android.os.Binder.execTransact

SyncAdapter vs JobScheduler

末鹿安然 提交于 2019-12-05 00:40:55
Excluding the fact that JobScheduler only supports API > 21 - are JobSchedulers designed to fully replace SyncAdapters ? Or does SyncAdapter contain any functionality lacking by JobScheduler ? My use case is syncing an RSS feed every couple of hours. This is doable with a JobScheduler - right? I would say JobScheduler is not a direct substitution for SyncAdapter , which has a much more specialized purpose (transferring data between the device and a server). JobScheduler , on the other hand, serves to schedule tasks to be executed at some point of time in future - just like AlarmManager - but

How to build a syncadapter for the google calendar?

穿精又带淫゛_ 提交于 2019-12-04 20:03:44
I'm building an application for students to manage the courses of a university. Now I would like to synchronize the events (an event has a date and time and a brief description) with the google calendar of Android. I took a look at the samplesync adapter from the Android sample, but I didn't find it very useful for the calendar. The sync of the app should be enabled and disabled from the settings of the app with a checkbox. Does anyone has some sample code that can be useful?? Use android.preference.PreferenceActivity to make your preference page. Ensure that your app updates the checkbox on

How to make a custom account show up like Google/LinkedIn/Facebook in the native Contacts app?

元气小坏坏 提交于 2019-12-04 14:36:44
问题 I'm currently working on an application, where we are going to be adding contacts from our own application, similar to how LinkedIn has connections and Facebook has friends. Therefore we want our custom account, that is shown in the images below (as " MyAppName ") with the contacts added from our application: We currently have a SyncAdapter as seen from the first image, as just wish for this to be shown in the Contacts application. We've been looking at documentation, but couldn't find

How to code a “sync now” operation on Android?

别来无恙 提交于 2019-12-04 12:35:22
问题 I have a sync adapter for my DB and at certain points in the application usage, it needs to sync the DB now. I would like to trigger the sync adapter as if its sync-time popped and then re-establish the sync time (i.e., 4 hours from this 'sync now" event). 回答1: I think (not tested) a better solution is already defined in the ContentResolver. ContentResolver.requestSync(account, authority, extras); so one might do the following: AccountManager am = AccountManager.get(context); Account account

How can I add a category to my SyncAdapter

僤鯓⒐⒋嵵緔 提交于 2019-12-04 10:40:01
I have tried the great Google example to sync contact from a webservice and that work fine. This is called the SampleSyncAdapter and really worth it: http://developer.android.com/resources/samples/SampleSyncAdapter/index.html I succed everything, but I cannot found in the example nor in the documentation a way to add a category that would link to a custom activity, exactly like the screenshot below: (I have only the sync account option with the checkbox) So, my question is: how can I add the account settings category? ehartwell herschel 's answer provides a link to a generic solution. Here's