I am preparing a login page for my app. I wanted to do the same thing that twitter is doing. They are helping the user and predefining some fields like email, name and prof
Get Account Full Name
First Add this permission into AndroidManifest.xml
file
Java Code
public 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;
}
Call getAccount();
Account account = getAccount(AccountManager.get(context));
String accountName = account.name;
String fullName = accountName.substring(0,accountName.lastIndexOf("@"));
emailEditText.setText(accountName);
fullNameEditText.setText(fullName);
If Account Email is -
abc@gmail.com
then Name is -
abc