意図を処理するアクティビティ{act = android.accounts.accountauthenticator}がありますが、

StackOverflow https://stackoverflow.com/questions/3133887

  •  01-10-2019
  •  | 
  •  

質問

ユーザーが選択したときにアプリケーションにログインアクティビティを表示しようとしています "アカウントを追加する"「アカウントと同期」 または、アプリケーションを使用したいが、まだログインしていない。例に従いました 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() 呼び出しますが、それでもその意図のためのアクティビティを見つけることができません。アカウントを介してアカウントを追加して同期しようとすると、アプリケーションが同じでクラッシュします ActivityNotFoundException.

私は何が間違っているのですか?

編集
C99のLast.FMアプリを調べました。これは、カスタムアクションを定義し、そのアクションに基づいて意図を使用しています。 android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT. 。それはより良いアプローチですか?アカウントと同期で動作させる方法はありますか?

役に立ちましたか?

解決

意図的なフィルターを入れます <category android:name="android.intent.category.DEFAULT" />

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top