正如文档中所说:
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);
}
}