No Activity found to handle Intent { act=android.accounts.AccountAuthenticator } even though I have one

StackOverflow https://stackoverflow.com/questions/3133887

  •  01-10-2019
  •  | 
  •  

Question

I'm trying to have my application display my login activity when a user selects "Add account" in "Accounts & Sync" or wants to use the application and isn't logged in yet. I've followed the example SampleSyncAdapter fairly closely, but can't get it to work and receive the following exception instead:

No Activity found to handle Intent { act=android.accounts.AccountAuthenticator }

My auth service contains:

public IBinder onBind(Intent intent) {
    IBinder ret = null;
    if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)){
        ret = getAuthenticator().getIBinder();
    }
    return ret;
}

My AndroidManifest.xml:

<service android:name=".auth.MyAuthService"
         android:exported="true" 
         android:process=":auth">
    <intent-filter>
        <action android:name="android.accounts.AccountAuthenticator" />
    </intent-filter>

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

My main activity:

startActivity(new Intent(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT));

I've tried doing both:

Intent svc = new Intent(this, CreazaAuthService.class);
startService(svc);

and:

bindService(new Intent(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT), null, BIND_AUTO_CREATE);

before the startActivity() call, but it still can't find an activity for that intent. If I try to add an account via accounts&sync my application crashes with the same ActivityNotFoundException.

What am I doing wrong?

EDIT
I've examined c99's last.fm app, which defines a custom action and uses intents based on that action rather than android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT. Is that a better approach? Is there a way to make it work with Accounts & Sync?

Was it helpful?

Solution

In your intent filter put <category android:name="android.intent.category.DEFAULT" />

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top