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, null);

or similar method:

ContentResolver.addPeriodicSync(
            ACCOUNT,
            AUTHORITY,
            Bundle.EMPTY,
            SYNC_INTERVAL);

https://developer.android.com/training/sync-adapters/running-sync-adapter.html

I strongly recommend this book, especially first 200 pages http://www.wrox.com/WileyCDA/WroxTitle/Enterprise-Android-Programming-Android-Database-Applications-for-the-Enterprise.productCd-1118183495.html .



来源:https://stackoverflow.com/questions/30931419/sync-adapter-not-calling-oncreate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!