質問

私はAndroidアプリのシンコアデッパーを実装しており、「アカウントと同期」メニューで利用可能なアカウントの設定をしたいと思います。私はこれをドロップボックスアプリで行ったことを見ました(下図のように)、これを行う方法に関するドキュメントを見つけることができませんでした。アカウントが追加されている場合は、このメニューのアカウント設定へのリンクを追加したいだけです。

画像の入力ここにある

役に立ちましたか?

解決

あなたのAndroidマニフェストの中で、あなたのアカウント認証者を定義するためにこのようなセクションを持つべきです:

<service android:name="AccountAuthenticatorService"
 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" />
</service>
.

上記のメタデータタグは、このようにアカウントを定義するXMLファイルを指す必要があります。

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="fm.last.android.account"
    android:icon="@drawable/icon"
    android:smallIcon="@drawable/icon"
    android:label="@string/app_name"
    android:accountPreferences="@xml/account_preferences"/>
.

Android:AccountPreferences属性は、設定画面を設定するXMLファイルを指します。

<PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
            android:title="General Settings" />

    <PreferenceScreen
        android:key="account_settings"
        android:title="Account Settings"
        android:summary="Sync frequency, notifications, etc.">
        <intent
            android:action="fm.last.android.activity.Preferences.ACCOUNT_SETUP"
            android:targetPackage="fm.last.android"
            android:targetClass="fm.last.android.activity.Preferences" />
    </PreferenceScreen>
</PreferenceScreen>
.

上記の設定画面は設定画面を表示する意図を起動しますが、XMLファイルに直接設定を定義することもできます。

他のヒント

正しく理解した場合は、アプリケーション内から「アカウントと同期設定」画面を表示します。このためには、設定の意図を発生させる必要があります。下記のコードを使用してください。

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.providers.subscribedfeeds","com.android.settings.ManageAccountsSettings"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
.

これが助けたことを願っています...

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