3

当用户在“帐户和同步”中选择“添加帐户”或想要使用该应用程序但尚未登录时,我试图让我的应用程序显示我的登录活动。我已经非常密切地遵循示例SampleSyncAdapter,但无法让它工作并收到以下异常:

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

我的身份验证服务包含:

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

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

我的主要活动:

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

我已经尝试过两种方法:

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

和:

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

startActivity()通话之前,但它仍然找不到该意图的活动。如果我尝试通过 accounts&sync 添加帐户,我的应用程序将崩溃,并使用相同的ActivityNotFoundException.

我究竟做错了什么?

编辑
我检查了 c99 的 last.fm 应用程序,它定义了一个自定义操作并使用基于该操作而不是android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT. 这是更好的方法吗?有没有办法让它与 Accounts & Sync 一起使用?

4

1 回答 1

12

在您的意图过滤器中放置<category android:name="android.intent.category.DEFAULT" />

于 2010-06-28T23:42:11.057 回答