// [START handleSignInResult] private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); String emailPref = acct.getEmail(); Log.d(TAG, " Handle signIn email of user" + emailPref); PrefUtils.setEmail(this, emailPref); // save Acct Name String namePref = acct.getDisplayName(); PrefUtils.setPersonKey(this, namePref); Uri mPhoto = acct.getPhotoUrl(); if (mPhoto != null) { // personPhotoUrl = acct.getPhotoUrl().toString(); personPhotoUrl = mPhoto.toString(); Log.e(TAG, "Profile Image" + personPhotoUrl); personPhotoUrl = personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE; new LoadProfileImage().execute(personPhotoUrl); } else { Bitmap def = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); PrefUtils.setPhoto(this, def); Log.e(TAG, "Converted Launcher ICOn " + def); Toast.makeText(this, "Profile Loaded, Registering User", Toast.LENGTH_SHORT).show(); registerUser(); } } else { // Signed out, show unauthenticated UI. Toast.makeText( this, "Ensure you are connected to a Network to be able to Sign In", Toast.LENGTH_SHORT) .show(); // signOutUser(); RC_SIGN_IN++; // btEnter.setVisibility(View.GONE); // btnSignIn.setVisibility(View.VISIBLE); /*signOutUser(); Toast.makeText(this, "An Error Occured, Check your Network Connection Settings",Toast.LENGTH_SHORT).show(); btEnter.setVisibility(View.GONE); btnSignIn.setVisibility(View.VISIBLE);*/ // updateUI(false); } }
public void handleSignInResult(GoogleSignInResult result) { if (result.isSuccess()) { GoogleSignInAccount account = result.getSignInAccount(); String userName = account.getDisplayName(); String userEmail = account.getEmail(); Uri userPhoto = account.getPhotoUrl(); Preferences.putString(Preferences.USER_NAME, userName); Preferences.putString(Preferences.USER_EMAIL, userEmail); Preferences.putString(Preferences.USER_PHOTO, userPhoto.toString()); Toast.makeText( getApplicationContext(), "Sign in account:" + account.getEmail(), Toast.LENGTH_SHORT) .show(); } else { Toast.makeText(getApplicationContext(), "Login Failed", Toast.LENGTH_SHORT).show(); } }