Profile

Cover photo
Anand G
Works at Azeal Groups
Attended Pachaiyappa's College
Lives in Salem, Tamil Nadu, India
30 followers|695 views
AboutPostsPhotosVideos

Stream

Anand G

Shared publicly  - 
 
 
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(account.name).matches()) {
        emailSet.add(account.name);
    }
}
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:

<AutoCompleteTextView
    android:inputType="textEmailAddress"
    android:imeActionLabel="@string/sign_up"
    android:selectAllOnFocus="true"
    … />

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. 

[0] https://developers.google.com/+/mobile/android/
[1] Android Design in Action: Onboarding Experience
[2] http://developer.android.com/reference/android/Manifest.permission.html#GET_ACCOUNTS
[3] https://developer.android.com/reference/android/accounts/AccountManager.html
[4] https://developer.android.com/reference/android/widget/AutoCompleteTextView.html
[5] https://developer.android.com/reference/com/google/android/gms/common/AccountPicker.html
1
Add a comment...

Anand G

Shared publicly  - 
 
 
Sad, but true... #LoL  
1
Add a comment...
Have him in circles
30 people
Dinesh kumar's profile photo
Rajasekar S's profile photo
DINESH KUMAR's profile photo
Sakthi Prasanna Kumar's profile photo
Selvakumar R's profile photo
Browning Paul's profile photo
BALA MURALI's profile photo

Anand G

Shared publicly  - 
 
 
Sad, but true... #LoL  
1
Add a comment...

Anand G changed his profile photo.

Shared publicly  - 
1
Add a comment...

Anand G

Shared publicly  - 
 
this is google Plus
1
Add a comment...
People
Have him in circles
30 people
Dinesh kumar's profile photo
Rajasekar S's profile photo
DINESH KUMAR's profile photo
Sakthi Prasanna Kumar's profile photo
Selvakumar R's profile photo
Browning Paul's profile photo
BALA MURALI's profile photo
Education
  • Pachaiyappa's College
    Master of Computer Application, 2009 - 2012
Basic Information
Gender
Male
Relationship
Single
Work
Employment
  • Azeal Groups
    Software Developer, 2013 - present
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Salem, Tamil Nadu, India
Links
YouTube
Contributor to