同步适配器不调用 onCreate
Sync Adapter not calling onCreate
我们是否需要启动同步适配器服务或框架隐式启动?我已经在 Sync Adapter 服务的 Constructor
、onCreate
、onDestroy
上记录了日志,当我启动应用程序时,我没有在 logcat 中看到日志。
但是当我在 activity onCreate
Intent serviceIntent = new Intent(context, SyncService.class);
context.startService(serviceIntent);
我看到了日志。
求推荐。
干杯,
拉吉
同步适配器通过调用显式启动:
ContentResolver.requestSync(ACCOUNT, AUTHORITY, null);
或类似方法:
ContentResolver.addPeriodicSync(
ACCOUNT,
AUTHORITY,
Bundle.EMPTY,
SYNC_INTERVAL);
https://developer.android.com/training/sync-adapters/running-sync-adapter.html
我强烈推荐这本书,尤其是前 200 页http://www.wrox.com/WileyCDA/WroxTitle/Enterprise-Android-Programming-Android-Database-Applications-for-the-Enterprise.productCd-1118183495.html。
我们是否需要启动同步适配器服务或框架隐式启动?我已经在 Sync Adapter 服务的 Constructor
、onCreate
、onDestroy
上记录了日志,当我启动应用程序时,我没有在 logcat 中看到日志。
但是当我在 activity onCreate
Intent serviceIntent = new Intent(context, SyncService.class);
context.startService(serviceIntent);
我看到了日志。
求推荐。
干杯, 拉吉
同步适配器通过调用显式启动:
ContentResolver.requestSync(ACCOUNT, AUTHORITY, null);
或类似方法:
ContentResolver.addPeriodicSync(
ACCOUNT,
AUTHORITY,
Bundle.EMPTY,
SYNC_INTERVAL);
https://developer.android.com/training/sync-adapters/running-sync-adapter.html
我强烈推荐这本书,尤其是前 200 页http://www.wrox.com/WileyCDA/WroxTitle/Enterprise-Android-Programming-Android-Database-Applications-for-the-Enterprise.productCd-1118183495.html。