Profile cover photo
Profile photo
Edward Vella
Edward's posts

Post has attachment
The bank of the future @getmondo is coming! Get early access with my link: 

Post has attachment

Post has shared content
Today’s  #AndroidDev   #Protip  from +Nick Butcher is about entering email addresses.

Entering data on mobile devices with on screen keyboards can be challenging; typing out email addresses can be particularly fiddly.   Anything you can do to ease this will be appreciated by your users and make them less likely to abandon your app.  While social identity providers (such as Google+ Sign-In [0][1]) can ease the process of signing in, there may be situations where you require direct input.

With the user’s permission [2], you can query the AccountManager [3] for accounts saved on the device.  You can then present these options, for example by using them as suggestions for an AutoCompleteTextView [4]:

final Account[] accounts = AccountManager.get(context).getAccounts();
final Set<String> emailSet = new HashSet<String>();
for (Account account : accounts) {
    if (Patterns.EMAIL_ADDRESS.matcher( {
List<String> emails = new ArrayList<String>(emailSet);
mEmailAutoCompleteView.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_dropdown_item_1line, emails));

Note that in the above snippet we’ve used a Set to de-duplicate accounts and a regex to only use accounts which are email addresses.

You can also ease entering email addresses not already known to the device by setting an appropriate keyboard layout and providing a meaningful action:

    … />

Not only will this technique ease data entry, but it will help prevent typos and remove the need to enter an address twice for verification (and double annoyance!)  If you have more tips for easier data entry, let us know in the comments.

Edit: Lots of good discussion in the comments about adding a permission for this functionality.  An alternative approach is to use the AccountPicker [5].  As this presents a system dialog to pick an account, it does not require the GET_ACCOUNTS permission.  This is a great alternative if you don’t need to customise the presentation. 

[1] Android Design in Action: Onboarding Experience


Post has attachment
Wait while more posts are being loaded