Reputation: 31
I have created my own custom account and that is working fine to add an account and to use it in the app.
I now want to be able to edit the account information instead of removing and adding an account. I have a number of fields on my account and some can be a bit lengthy, so removing and adding is rather cumbersome.
I have created the basics for this by adding my own PreferenceScreen and connected it via the android:accountPreferences in my account-authenticator XML file as per the example here: AbstractAccountAuthenticator.
In my PreferenceScreen I define an intent to open my activity that is used to enter the user data for the account.
<PreferenceScreen
android:key="edit"
android:title="Edit Account Details"
android:summary="Change System ID, user name, password etc.">
<intent
android:action="my.app.accountmanager.UserCredentialsActivity.ACCOUNT_SETUP"
android:targetPackage="my.app.accountmanager"
android:targetClass="my.app.accountmanager.UserCredentialsActivity" />
</PreferenceScreen>
My issue is, how do I either pass along as extras in the intent or find the account information for the account I selected in the Settings/Accounts & Sync. It is possible to have multiple accounts of this custom account type, so I can't just search for any account of that type. I need the data from the selected account.
My thoughts have roughly been in these areas:
I hope this is possible to do as both a Samsung app and the Dropbox app do this from the Accounts & Sync, although neither allow multiple accounts...
Upvotes: 3
Views: 963
Reputation: 1630
I think the accountPreferences attribute in AbstractAccountAuthenticator is going to be obsolete soon. If you look at the accounts in JB, if you add multiple accounts, it is going to be displayed like this
Instead of
And if you take a look at the Gmail app, the preferences (notifcation ringtone) for Gmail is configured within the Gmail app itself, and can't be configured from the Accounts & Settings page.
So, you should only use the accountPreferences attributes for preferences that are common to all accounts.
Upvotes: 1