android-syncadapter

Syncing a REST service with an android app

痞子三分冷 提交于 2019-12-09 15:45:07
问题 There's a REST service that I use to populate info in my database, that is later used by my app. I've read several threads on the matter, and now have to decide how I want the sync between the REST service and my DB to work. Think of an app that gets info from google finance APIs about stocks and stores it in a DB, displays the information when the app is launched, and sends notifications when specific events happen in the stock price. I already implemented the simple option of AsyncTask that

AccountManager does not add custom account in Android N preview

偶尔善良 提交于 2019-12-09 14:54:08
问题 I have implemented a sync adapter in my app which requires an account to be added in the device account settings. I followed the same approach given in the Android docs. It works fine till Marshmallow and I can see my account listed in the device accounts. But in Android N preview, account does not add to the device accounts. AccountManager's addAccountExplicitly() method always returns false. Has anyone faced this problem? 回答1: Not sure if this is the same issue, but there's an issue with

SharedPreference committed in SyncAdapter not updated in Activity?

痴心易碎 提交于 2019-12-09 14:34:57
问题 I am changing and committing a SharedPreference in my SyncAdapter after successful sync, but I am not seeing the updated value when I access the preference in my Activity (rather I am seeing the old value). What am I doing wrong? Different Contexts? My SyncAdapter where I update the preference: class SyncAdapter extends AbstractThreadedSyncAdapter { private int PARTICIPANT_ID; private final Context mContext; private final ContentResolver mContentResolver; public SyncAdapter(Context context,

SyncAdapter not getting called on “Network tickle”

女生的网名这么多〃 提交于 2019-12-08 16:01:29
问题 Overview I follwed Google's tutorial on using SyncAdapter without using ContentProvider, Authenticator..etc. It works perfectly when I call onPerformSync(...) when I need to do an "upload" to the server via de SyncAdapter. Now, as you can imagine, I need to do downloads from the server as well (yes I understand that it would be better to use Google's Cloud Messaing system, but this is the set up I was given, and I can't change that). For that, instead of doing periodical syncs, I want to make

How to add custom app tag in native android contact app?

社会主义新天地 提交于 2019-12-08 15:26:50
问题 I am developing an app and the requirement is to show the app icon in native contact app of android for the contacts who are also using my app i.e. they have installed and registered on my app. I want to show WhatsApp kind label in contacts. Please see these two images for reference I am fetching all the contacts and sending them to server which returns with the list of contacts who are using my app. Only for those contacts I have to show my app icon in contact app. I read lot of resources

Sync Adapter not calling onCreate

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 14:09:19
问题 Do we need to start the Sync Adapter service or framework starts implicitly? I have put a log on Constructor , onCreate , onDestroy of Sync Adapter service and when I start the app, I don't see the logs in the logcat. But when I do on activity onCreate Intent serviceIntent = new Intent(context, SyncService.class); context.startService(serviceIntent); I see the logs. Please suggests. Cheers, Raj 回答1: Sync adapter starts explicitly by calling: ContentResolver.requestSync(ACCOUNT, AUTHORITY,

infinite sync loop syncadapter

落花浮王杯 提交于 2019-12-08 10:44:47
问题 I have the same problem stated here: Android SyncAdapter stuck in infinite sync loop But after trying to implement the notifychange (Uri uri, ContentObserver observer, boolean syncToNetwork) in onPerformSync, I realized that I didn't know how to get the ContentObserver that I needed (which is defined and passed in in the main activity) Any tips? EDIT 1: like this person First time sync loops indefinitely I found that ContentResolver.cancelSync(account, authority); will work as well, but if

SyncAdapter stays awake for hours on end

戏子无情 提交于 2019-12-08 03:30:04
问题 My Android app uses a SyncAdapter to sync with my API service. I use delayUntil to tell it to only sync every half an hour. However, some users are reporting incidents where it never goes to sleep again once it's done, draining the phone battery (e.g. the app shows up in the device's battery page showing a "Keep awake" of 13 hours+). I'm also certain there's no infinite loops in the onPerformSync method - it makes a few HTTP calls and updates the database and that's about it. Has anybody else

Refreshing fragments in FragmentActivity after sync service runs

左心房为你撑大大i 提交于 2019-12-07 16:25:12
问题 does anybody have any elegant solution for refreshing the Views in Fragments in a FragmentActivity's ViewPager after a sync Service from a SyncAdapter runs? I've tried calling notifyDataSetChanged() and notifyDataSetInvalidated() on my adapter, as well as refreshDrawableState() on my views ( GridViews ), but to no avail. Perhaps I've been calling them from the wrong places -- I've tried doing it at setUserVisibleHint where isVisible =true, hoping to trigger it whenever the fragment comes into

Android : Sync Adapter not running in some devices

本秂侑毒 提交于 2019-12-07 15:19:01
问题 In my android project i have a sync adapter that will sync data from android device to the server and its working fine, but recently i noticed that the onPerfomSync is not calling in my moto g3 android phone, I don't know whether there is the same problem in any other phones,I have tested it in some other Samsung phones with different android api level,but didn't find any problem there.I have configured the sync when a successful user login found.What will be the reason for this behaviour