0
我已經構建了一個帳戶同步適配器,以顯示本地通訊錄中應用程序的聯繫人。onPerformSync在模擬器上調用但不是物理設備
有一個虛假authonticator,提供帳戶。還交代是可同步
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
此帳戶顯示在設備上的所有帳戶:
我試圖通過系統觸發onPerformSync - 在菜單中按從設置「立即同步」和編程:
public static void triggerRefresh() {
Bundle b = new Bundle();
b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
Account account = AccountAuthenticatorService.GetAccount();
if (ContentResolver.isSyncPending(account, ContactsContract.AUTHORITY) ||
ContentResolver.isSyncActive(account, ContactsContract.AUTHORITY)) {
ContentResolver.cancelSync(account, ContactsContract.AUTHORITY);
}
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
ContentResolver.requestSync(
account, // Sync account
ContactsContract.AUTHORITY,authority
b);
}
它工作在模擬器罰款,但在多個設備(索尼,三星),它不是在所有觸發(我已經竭力試圖o在onPerformSync方法中記錄日誌但從未看到此日誌)。
我試圖找到這樣的問題,但沒有什麼幫助,我不能讓onPerformSync強制被調用。
根據syncAdapter,仿真器和設備之間的主要區別是什麼?