I have a simple google authentication app and I want to show a welcome message. If the email account is j ohnsmith@gmail.com , I want Toast with "welcome John Smith!" . How can i do this?
This is my code:
if (user == null) { startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().build(), SIGN_IN_REQUEST_CODE); } else { Toast.makeText(MainActivity.this, "Welcome " + userName, Toast.LENGTH_SHORT).show(); }
I tried to use this code, but I only get the username and not the first and last name.
AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE); Account[] list = manager.getAccounts();
Thanks in advance!
source share