Authenticator account lost when moving application to SD card

when I move my testapp to the SD card, my user account authenticator (com.heidi.AccountStuff) no longer exists.

if I added a new account like this

Account account = new Account("heidi", AccountAuthenticatorService.TYPE);
AccountManager accountManager = AccountManager.get(this);
accountManager.addAccountExplicitly(account, "", null);

it will throw a RuntimeException

java.lang.SecurityException: caller uid XXXXX is different than the authenticator uid 

ok, make sense, beacause when I output autatatortypes (with the following code snippet):

    for(AuthenticatorDescription d: accountManager.getAuthenticatorTypes()) {
        Log.d("add", d.toString());
    }

he will output

AuthenticatorDescription {type=com.htc.linkedin}
AuthenticatorDescription {type=com.htc.android.mail.eas}
AuthenticatorDescription {type=com.htc.sync.provider.weather}
AuthenticatorDescription {type=com.htc.android.windowslive}
AuthenticatorDescription {type=com.htc.android.mail}
AuthenticatorDescription {type=com.htc.stock}
AuthenticatorDescription {type=com.htc.lucy.account}
AuthenticatorDescription {type=com.google}

after moving the application to the internal storage, my custom display type on output, for example:

AuthenticatorDescription {type=com.heidi.AccountStuff}
AuthenticatorDescription {type=com.htc.linkedin}
AuthenticatorDescription {type=com.htc.android.mail.eas}
AuthenticatorDescription {type=com.htc.sync.provider.weather}
AuthenticatorDescription {type=com.htc.android.windowslive}
AuthenticatorDescription {type=com.htc.android.mail}
AuthenticatorDescription {type=com.htc.stock}
AuthenticatorDescription {type=com.htc.lucy.account}
AuthenticatorDescription {type=com.google}

any ideas?

+4
source share
1 answer

There are several parts to creating a user account ...

To call AccountManager in your activity, you already implemented something similar ...

  Account account = new Account(username, ACCESS_TYPE);
  AccountManager am = AccountManager.get(this);
  Bundle userdata = new Bundle();
  userdata.putString("SERVER", "extra");

  if (am.addAccountExplicitly(account, password, userdata)) {
   Bundle result = new Bundle();
   result.putString(AccountManager.KEY_ACCOUNT_NAME, username);
   result.putString(AccountManager.KEY_ACCOUNT_TYPE, ACCESS_TYPE);
   setAccountAuthenticatorResult(result);
  }

res/xml/authenticator.xml AccountAuthenticator ( ). ACCESS_TYPE , accountType xml!

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="de.buecherkiste"
android:icon="@drawable/buecher"
android:label="@string/app_name"
android:smallIcon="@drawable/buecher" >
</account-authenticator>

, . (AUTHENTICATE_ACCOUNTS/USE_CREDENTIALS/GET_ACCOUNTS/MANAGE_ACCOUNTS)

<service android:name="AuthenticatationService">

<intent-filter>
    <action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
    android:resource="@xml/authenticator" />

</service>
+3

All Articles