Profile

Cover photo
Anand G
Worked at Loading ... ████████████ 99.9%
Attended Pachaiyappa's College
Lives in Salem, Tamil Nadu, India
58 followers|8,625 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
58 people
Kumar K.G's profile photo
Aristo Michael's profile photo
Satheeshbabu M's profile photo
David R's profile photo
Karthik VN's profile photo
karthik fot's profile photo
Job Info Solutions's profile photo
Fazal Rehman's profile photo
Prakasam Mathaiyan'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
58 people
Kumar K.G's profile photo
Aristo Michael's profile photo
Satheeshbabu M's profile photo
David R's profile photo
Karthik VN's profile photo
karthik fot's profile photo
Job Info Solutions's profile photo
Fazal Rehman's profile photo
Prakasam Mathaiyan's profile photo
Work
Employment
  • Loading ... ████████████ 99.9%
    Loading ... ████████████ 99.9%, 1901 - 9999
    Loading ... ████████████ 99.9%
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
Story
Tagline
Be the best...
Education
  • Pachaiyappa's College
    Master of Computer Application, 2009 - 2012
Basic Information
Gender
Male
Relationship
Single
Apps with Google+ Sign-in
  • Death Moto
  • Mission Impossible RogueNation
  • DEER HUNTER 2016
  • Real Boxing
  • FRONTLINE COMMANDO 2
  • CONTRACT KILLER 3
  • FRONTLINE COMMANDO:D-DAY