Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide dummy Account for Sync Adapter from Settings

Tags:

I have created a Sync Adapter with a dummy Account and I don't want it to appear on the Account list in the Settings application, nor when a user presses the add account button in Settings. I have tried android:userVisible="false" in my sync-adapter definition, but still the account appears. I've tried this on an emulator and 3 physical devices. Everything works correctly in terms that it syncs all the data I need, the only thing wrong is that I see the Account on the list, and I don't want to.

My authenticator.xml is:

<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"     /> 

My syncadapter.xml is:

<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"     /> 

And I add my adpater like this:

 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);  } 

And the I get the account on the account list and in the add account list.

Help please! :)

like image 506
Astagor Avatar asked Oct 24 '13 09:10

Astagor


1 Answers

I found the solution. This is how authenticator.xml should look like:

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"                    android:accountType="net.astagor.android.hhp.account"      /> 

You must not have these lines:

               android:icon="@drawable/ic_launcher"                android:smallIcon="@drawable/ic_launcher"                android:label="@string/app_name" 

If you put them, the account will be visible wherever you set android:userVisible="false" or not.

like image 149
Astagor Avatar answered Sep 28 '22 08:09

Astagor