I want to create custom app account in settings.
settings > Add account
but no nameAuthenticatorActivity
doesn't start. I debug Authenticator
class, addAccount
method is called but no activity popped.I did the following steps:
public class AccountAuthenticator extends AbstractAccountAuthenticator{
@Override
public Bundle addAccount(AccountAuthenticatorResponse response,
String accountType, String authTokenType,
String[] requiredFeatures, Bundle options)
throws NetworkErrorException {
final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
intent.putExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType);
intent.putExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
final Bundle bundle = new Bundle();
bundle.putParcelable(AccountAuthenticator.KEY_INTENT, intent);
return bundle;
}
}
public class AuthenticatorService extends Service{
@Override
public IBinder onBind(Intent intent) {
authenticator = new AccountAuthenticator(this);
return authenticator.getIBinder();
}
}
<service android:name="com.voillo.utils.AuthenticatorService" android:exported="false"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.example.myapp"
android:icon="@drawable/myapp_icon"
android:smallIcon="@drawable/myapp_icon_small"
android:label="myapp"
/>
Chances are high that you forgot to declare the Activity on your Manifest File. I encountered the same error and found out that I forgot to declare my activity on the project's Manifest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With