Tôi đã tạo Bộ điều hợp Đồng bộ với Tài khoản giả và tôi không muốn nó xuất hiện trong danh sách Tài khoản trong ứng dụng Cài đặt hoặc khi người dùng nhấn nút thêm tài khoản trong Cài đặt . Tôi đã thử android: userVisible = "false" trong định nghĩa bộ điều hợp đồng bộ hóa của tôi, nhưng vẫn xuất hiện tài khoản. Tôi đã thử điều này trên một trình giả lập và 3 thiết bị vật lý. Mọi thứ hoạt động chính xác theo nghĩa nó đồng bộ tất cả dữ liệu tôi cần, điều duy nhất sai là tôi thấy Tài khoản trong danh sách và tôi không muốn.Ẩn Tài khoản giả cho Bộ điều hợp Đồng bộ từ Cài đặt
authenticator.xml của tôi là:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="net.astagor.android.hhp.account"
android:icon="@drawable/ic_launcher"
android:smallIcon="@drawable/ic_launcher"
android:label="@string/app_name"
/>
syncadapter.xml của tôi là:
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="net.astagor.android.hhp"
android:accountType="net.astagor.android.hhp.account"
android:userVisible="false"
android:supportsUploading="true"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"
/>
Và tôi thêm adpater của tôi như thế này:
Account account = AuthenticatorService.GetAccount();
AccountManager accountManager = (AccountManager) context
.getSystemService(Context.ACCOUNT_SERVICE);
if (accountManager.addAccountExplicitly(account, null, null)) {
ContentResolver.setIsSyncable(account, StubProvider.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account,
StubProvider.AUTHORITY, true);
ContentResolver.addPeriodicSync(account, StubProvider.AUTHORITY,
new Bundle(), SYNC_FREQUENCY);
}
Và tôi nhận được tài khoản trên danh sách tài khoản và trong danh sách thêm tài khoản.
Trợ giúp xin vui lòng! :)
Tôi rất quan tâm đến câu trả lời của câu hỏi này (nếu có cách nào tốt hơn) –
Cùng một vấn đề ở đây. Mất tất cả mọi thứ từ các tài liệu giống như bạn - không muốn một dummyaccount được hiển thị, nhưng nó chỉ đơn giản là luôn luôn cho thấy! :-(Điều gì bị hỏng ở đây? – Zordid