2012-05-18 15 views
14

アンドロイドアプリのsyncadapterを実装していて、「アカウント&同期」メニューでアカウントの設定を有効にしたいとします。私はこれをDropBoxアプリケーション(以下に示す)で行ったのを見てきましたが、これを行う方法に関するドキュメントを見つけることができませんでした。アカウントを追加しました。このメニューのアカウント設定へのリンクを追加したいだけです。アカウントの設定を表示してアンドロイドアプリの同期メニュー

enter image description here

答えて

22

を助け、あなたのアカウント認証を定義するには、このようなセクションを持つ必要があります希望:

<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"/> 

androi D:

<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> 

上記PreferenceScreenは、設定画面を表示する意図を起動しますが、あなたはまた、XMLで直接設定を定義することができますaccountPreferencesはそうのように、あなたの好みの画面を定義するXMLファイルに上記の点を属性ファイル。

+0

お返事ありがとう! – Patrick

+0

この古いqsn! *インテントインテント=新しいインテント(Settings.ACTION_SYNC_SETTINGS); // ACTION_SETTINGS startActivity(intent); *設定画面を起動しません!! –

0

私が正しく理解している場合、あなたが表示したいアプリケーション内から画面「&同期設定のアカウント」。このためには、設定のための意図を発する必要があります。

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); 

これはあなたのAndroidマニフェストでは...

+0

これは私がやろうとしていることではありません。私は上記の図に示されているように.accountsメニューの下に "一般的な設定"を追加しようとしています – Patrick

関連する問題