tags:

views:

62

answers:

1

I'm trying to have my app display my login activity when a user selects add account in accounts&sync or wants to use the app and isn't logged in yet. I've followed the example SampleSyncAdapter fairly closely, but can't get it to work.

in my auth service:

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

in my manifest:

<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" />

in 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 the app 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?

+1  A: 

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

Qberticus
Awesome. Thank you!
OhHiThere