在 api 11 之前使用 AbstractThreadedSyncAdapter
Using AbstractThreadedSyncAdapter before api 11
如何为低于API-11的minSDK使用AbstractThreadedSyncAdapter?以下构造函数抱怨需要 API-11.
public DogSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
super(context, autoInitialize, allowParallelSyncs);
}
正如文档中所说:
Api 5 级:
public AbstractThreadedSyncAdapter (Context context, boolean autoInitialize)
Api 11 级:
public AbstractThreadedSyncAdapter (Context context, boolean autoInitialize, boolean allowParallelSyncs)
所以你只需要实现两个构造函数,然后调用一个或另一个:
if (sSyncAdapter == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
sSyncAdapter = new NotificationsSyncAdapter(getApplicationContext(), true, true);
} else {
sSyncAdapter = new NotificationsSyncAdapter(getApplicationContext(), true);
}
}
如何为低于API-11的minSDK使用AbstractThreadedSyncAdapter?以下构造函数抱怨需要 API-11.
public DogSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
super(context, autoInitialize, allowParallelSyncs);
}
正如文档中所说:
Api 5 级:
public AbstractThreadedSyncAdapter (Context context, boolean autoInitialize)
Api 11 级:
public AbstractThreadedSyncAdapter (Context context, boolean autoInitialize, boolean allowParallelSyncs)
所以你只需要实现两个构造函数,然后调用一个或另一个:
if (sSyncAdapter == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
sSyncAdapter = new NotificationsSyncAdapter(getApplicationContext(), true, true);
} else {
sSyncAdapter = new NotificationsSyncAdapter(getApplicationContext(), true);
}
}