其他分享
首页 > 其他分享> > 找不到活动来处理Intent {act = android.accounts.AccountAuthenticator}即使我有一个

找不到活动来处理Intent {act = android.accounts.AccountAuthenticator}即使我有一个

作者:互联网

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

找不到处理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”/>

标签:android,android-syncadapter
来源: https://codeday.me/bug/20190715/1472434.html