ユーザーが[アカウントと同期]で[アカウントの追加]を選択したとき、またはアプリケーションを使用したいがまだログインしていないときに、アプリケーションにログインアクティビティを表示させようとしています。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()
、しかしそれはまだその意図のための活動を見つけることができません。account&syncを介してアカウントを追加しようとすると、同じでアプリケーションがクラッシュしますActivityNotFoundException
。
私は何が間違っているのですか?
編集
私はc99のlast.fmアプリを調べました。これは、カスタムアクションを定義し、ではなくそのアクションに基づいてインテントを使用しandroid.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT
ます。それはより良いアプローチですか?Accounts&Syncで動作させる方法はありますか?