Android examples for Account:Email Address
get Email from Context
//package com.book2s; import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; public class Main { public static String getEmail(Context context) { AccountManager accountManager = AccountManager.get(context); Account account = getAccount(accountManager); if (account == null) { return null; } else {//from w w w. j a va 2s . com return account.name; } } private static Account getAccount(AccountManager accountManager) { Account[] accounts = accountManager.getAccountsByType("com.google"); Account account; if (accounts.length > 0) { account = accounts[0]; } else { account = null; } return account; } }