I have a suite of apps and my AccountManager files live in one central app. I can use AccountManager.AddAccount() in that central app, but when I try to use that method from the other apps, the AuthenticatorActivity is not started. I can debug and see that all of the code from AddAccount is being executed, but the activity is never launched.
Here is my AddAccount method:
public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options)
{
var intent = new Intent(_context, typeof(MyAccountAuthenticatorActivity));
intent.PutExtra(MyAccountAuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType);
intent.PutExtra(MyAccountAuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
intent.PutExtra(MyAccountAuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
var bundle = new Bundle();
bundle.PutParcelable(AccountManager.KeyIntent, intent);
return bundle;
}
I use the same splash screen in all of my apps, so the code that calls AddAccount is the same.
_accountManager = AccountManager.Get(this);
var accounts = _accountManager.GetAccountsByType(AccountKeys.ACCOUNT_TYPE);
//automatically add new account if no users on device yet
if (accounts.Length == 0)
{
_accountManager.AddAccount(AccountKeys.ACCOUNT_TYPE, AccountKeys.AUTH_TYPE, null, null, this, null, null);
CheckIfFirstRun();
Finish();
}
MyAccountAuthenticatorActivity is located in one app. As you can see, I am sending in the correct activity context to AddAccount but StartActivity() is only called when those code is executed in the app that owns the authenticator files.
What else am I missing to allow my other apps to open up MyAccountAuthenticatorActivity? Could it be possible that it has to do with setting the callback to null when I call AddAccount? I cannot figure out how to do this another way as I do not fully understand how to use the callback because none of the java examples have this.
I have also tried adding the MyAccountAuthenticatorActivity to the manifest of my other app like so:
<activity android:name="com.redacted.authenticator.MyAccountAuthenticatorActivity" />
But this doesn't change anything. I know the other apps are seeing the AuthenticatorService, they just won't launch the activity.
See Question&Answers more detail:
os