当用户选择时,我正在尝试使我的应用程序显示我的登录活动 “新增帐户”“帐户与同步” 或想使用该应用程序,但尚未登录。我效法了这个例子 样品合成器 相当紧密,但无法使其工作并获得以下例外:

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() 呼叫,但仍然找不到该意图的活动。如果我尝试通过帐户添加帐户并同步我的应用程序崩溃与相同 ActivityNotFoundException.

我究竟做错了什么?

编辑
我已经检查了C99的Last.fm应用程序,该应用程序定义了自定义操作并根据该动作而不是 android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT. 。这是更好的方法吗?有没有办法使其与帐户和同步合作?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top