Reputation: 69
I am trying to make the users choose from a list of custom accounts of the same type using an AccountPicker.
Intent pickAccountIntent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.home.customapp"}, true, null, null, null, null);
startActivityForResult(pickAccountIntent, 1);
I have 2 issues:
1.
According to the API, if the alwaysPromptForAccount
(4th parameter) is set to true the picker should be always visible.
However if there are no previous accounts of type "com.home.customapp", the picker activity is not displayed even if the alwaysPromptForAccount
is set to true
How can I make the picker be always visible even if there are no custom accounts?
2. How can the add account steps be customized on order to add a custom account, not a google account?
Upvotes: 5
Views: 3087
Reputation: 9111
I just figured out that the flag only affects the case when there is exactly one account of that type. It has no effect on the case where there are zero accounts.
If there are zero accounts, regardless of the true
/false
value of the parameter, the picker dialog will be bypassed, and the system will immediately launch the Create Account Intent.
If there is exactly one account, and the flag is true
, it will show the options to use that account or create a new account. If the flag is false
, it will immediately login using the account, without giving the option to create a new account.
Upvotes: 4
Reputation: 2899
To add an account you can use:
mAccountMgr.addAccountExplicitly(mAccount, null, null);
setAccountSync(mAccount, SOME_AUTHORITY, some_interval);
Is this what you're looking for?
Upvotes: 0