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

10,893

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

Share:
10,893
juell
Author by

juell

Updated on June 28, 2022

Comments

  • juell
    juell almost 2 years

    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?