Beispiel #1
0
 @Override
 public void onClick(View v) {
   if (!mGoogleApiClient.isConnecting()) {
     // We only process button clicks when GoogleApiClient is not
     // transitioning between connected and not connected.
     switch (v.getId()) {
       case R.id.sign_in_button:
         mStatus.setText(R.string.status_signing_in);
         resolveSignInError();
         break;
       case R.id.sign_out_button:
         // We clear the default account on sign out so that Google
         // Play services will not return an onConnected callback
         // without user interaction.
         Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
         mGoogleApiClient.disconnect();
         mGoogleApiClient.connect();
         break;
       case R.id.revoke_access_button:
         // After we revoke permissions for the user with a
         // GoogleApiClient instance, we must discard it and create a
         // new one.
         Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
         // Our sample has caches no user data from Google+, however
         // we would normally register a callback on
         // revokeAccessAndDisconnect to delete user data so that we
         // comply with Google developer policies.
         Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient);
         mGoogleApiClient = buildGoogleApiClient();
         mGoogleApiClient.connect();
         break;
     }
   }
 }
  @Override
  public void onConnected(Bundle bundle) {
    gPlusEmail = Plus.AccountApi.getAccountName(googleApiClient);
    Person person = Plus.PeopleApi.getCurrentPerson(googleApiClient);
    if (person != null) {
      if (person.hasName()) {
        gPlusFullName = "";
        if (person.getName().hasGivenName()) {
          gPlusFullName += person.getName().getGivenName() + " ";
        }
        if (person.getName().hasMiddleName()) {
          gPlusFullName += person.getName().getMiddleName() + " ";
        }
        if (person.getName().hasFamilyName()) {
          gPlusFullName += person.getName().getFamilyName();
        }
      }
      if (person.hasId()) {
        gPlusId = person.getId();
      }
    }
    if (gPlusSignInClicked) {
      Log.d("LOGIN", "Starting Authentication Service...");

    } else {
      Plus.AccountApi.clearDefaultAccount(googleApiClient);
      Plus.AccountApi.clearDefaultAccount(googleApiClient);
      googleApiClient.disconnect();
    }
    gPlusSignInClicked = false;
  }
Beispiel #3
0
  // [START on_disconnect_clicked]
  private void onDisconnectClicked() {
    // Revoke all granted permissions and clear the default account.  The user will have
    // to pass the consent screen to sign in again.
    if (mGoogleApiClient.isConnected()) {
      Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
      Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient);
      mGoogleApiClient.disconnect();
    }

    showSignedOutUI();
  }
 public void revokeGplusAccess() {
   if (mGoogleApiClient.isConnected()) {
     Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
     Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient)
         .setResultCallback(
             new ResultCallback<Status>() {
               @Override
               public void onResult(Status arg0) {
                 Log.e(TAG, "User access revoked!");
                 mGoogleApiClient.connect();
                 updateUI(false);
               }
             });
   }
 }
Beispiel #5
0
  private void updateUI(boolean isSignedIn) {
    if (isSignedIn) {
      Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
      if (currentPerson != null) {
        // Show signed-in user's name
        String name = currentPerson.getDisplayName();
        mStatus.setText(getString(R.string.signed_in_fmt, name));

        // Show users' email address (which requires GET_ACCOUNTS permission)
        if (checkAccountsPermission()) {
          String currentAccount = Plus.AccountApi.getAccountName(mGoogleApiClient);
          ((TextView) recViewLogin.findViewById(R.id.email)).setText(currentAccount);
        }
      } else {
        // If getCurrentPerson returns null there is generally some error with the
        // configuration of the application (invalid Client ID, Plus API not enabled, etc).
        Log.w(TAG, getString(R.string.error_null_person));
        mStatus.setText(getString(R.string.signed_in_err));
      }

      // Set button visibility
      recViewLogin.findViewById(R.id.sign_in_button).setVisibility(View.GONE);
      recViewLogin.findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
    } else {
      // Show signed-out message and clear email field
      mStatus.setText(R.string.signed_out);
      ((TextView) recViewLogin.findViewById(R.id.email)).setText("");

      // Set button visibility
      recViewLogin.findViewById(R.id.sign_in_button).setEnabled(true);
      recViewLogin.findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
      recViewLogin.findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
    }
  }
Beispiel #6
0
  private void setGResult() {
    Person signedInUser = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);

    if (signedInUser != null) {
      if (signedInUser.hasDisplayName()) {
        guname = signedInUser.getDisplayName();
      }

      guemail = Plus.AccountApi.getAccountName(mGoogleApiClient);

      // Toast.makeText(getApplicationContext(),guemail,Toast.LENGTH_LONG).show();
      if (signedInUser.hasImage()) {
        String[] profileparts = signedInUser.getImage().getUrl().split("\\?");
        guserProfilePicUrl = profileparts[0];
      }
      if (signedInUser.hasBirthday()) {
        bday = signedInUser.getBirthday();
        Toast.makeText(getApplicationContext(), bday, Toast.LENGTH_LONG).show();
      }
      if (signedInUser.hasGender()) {
        gender = String.valueOf(signedInUser.getGender());
        Toast.makeText(getApplicationContext(), gender, Toast.LENGTH_LONG).show();
      }
      pref = getApplicationContext().getSharedPreferences("unid", MODE_APPEND);
      SharedPreferences.Editor editor = pref.edit();
      editor.putString("unid", guemail);
      editor.commit();

      new Makerqust().execute();
    }
  }
  /** Sign out and disconnect from the APIs. */
  public void signOut() {
    if (!mGoogleApiClient.isConnected()) {
      // nothing to do
      debugLog("signOut: was already disconnected, ignoring.");
      return;
    }

    // for Plus, "signing out" means clearing the default account and
    // then disconnecting
    if (0 != (mRequestedClients & CLIENT_PLUS)) {
      debugLog("Clearing default account on PlusClient.");
      Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
    }

    // For the games client, signing out means calling signOut and
    // disconnecting
    if (0 != (mRequestedClients & CLIENT_GAMES)) {
      debugLog("Signing out from the Google API Client.");
      Games.signOut(mGoogleApiClient);
    }

    // Ready to disconnect
    debugLog("Disconnecting client.");
    mConnectOnStart = false;
    mConnecting = false;
    mGoogleApiClient.disconnect();
  }
  /** Fetching user's information name, email, profile pic */
  private void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        personName = currentPerson.getDisplayName();
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        email = Plus.AccountApi.getAccountName(mGoogleApiClient);

        Log.e(
            TAG,
            "Name: "
                + personName
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + personPhotoUrl);

      } else {
        Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void checkuser() {

    Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
    String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
    String personName = currentPerson.getDisplayName();

    try {

      long timeInMillis = System.currentTimeMillis();

      final String PhoneModel = android.os.Build.MODEL;
      JSONObject userData = new JSONObject();
      userData.put("phoneModel", PhoneModel);
      userData.put("username", personName);
      userData.put("email", email);
      Log.d(TAG, userData.toString());
      String response = CommonFunctions.sendRequestToServer(userData.toString(), "login");
      if (response.contains("SUCCESS") || response.contains("ALREADY")) {
        Log.d("testing", response);
        String userid = response.subSequence(13, 17).toString();
        // Log.d("testing", userid);
        saveSharedString("USERID", userid);
        // initialsetup();
        // SensingController.unregisterAlarm(getApplicationContext());
      }

    } catch (Exception e) {
      Log.e(TAG, e.toString());
    }
  }
  @Override
  public void onConnected(Bundle bundle) {
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
      Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
      String personName = currentPerson.getDisplayName();
      String personPhoto = currentPerson.getImage().getUrl();
      String firstName = currentPerson.getName().getGivenName();
      String lastName = currentPerson.getName().getFamilyName();
      String personGooglePlusProfile = currentPerson.getUrl();
      String date = currentPerson.getBirthday();
      if (date == null) {
        date = "";
      }
      int gender = currentPerson.getGender();
      String email = Plus.AccountApi.getAccountName(mGoogleApiClient);

      Intent mIntent = new Intent(getActivity(), LoginUserDetails.class);
      mIntent.putExtra("login_method", "google");
      mIntent.putExtra("email", email);
      mIntent.putExtra("first_name", firstName);
      mIntent.putExtra("gender", gender);
      mIntent.putExtra("last_name", lastName);
      mIntent.putExtra("photo", personPhoto);

      mixpanel.track("Login - Google");
      startActivity(mIntent);
    } else {
      Toast.makeText(getContext(), "You do not have a google+ account", Toast.LENGTH_SHORT).show();
      showSocialLoginDialog();
    }

    Log.d(TAG, "onConnected:" + bundle);
    mShouldResolve = false;
  }
 private void googlePlusLogout() {
   if (mGoogleApiClient.isConnected()) {
     Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
     mGoogleApiClient.disconnect();
     mGoogleApiClient.connect();
   }
 }
  private void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);

        Log.e("GetInfo", currentPerson.toString());

        Gplus_name = currentPerson.getDisplayName();
        Gplus_image = currentPerson.getImage().getUrl();
        Gplus_email = Plus.AccountApi.getAccountName(mGoogleApiClient);
        Gplus_id = currentPerson.getId();
        Log.e("GetInfoID", Gplus_id);

        if (Gplus_id != null) {

          context.runOnUiThread(
              new Runnable() {
                @Override
                public void run() {

                  login_type = "gplus";
                  GlobalClaass.savePrefrencesfor(context, PreferenceConnector.Gplus_ID, Gplus_id);

                  CallFacebookLogin(login_type, Gplus_id, Gplus_email);
                }
              });
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  private void onSignOutClicked() {
    if (mGoogleApiClient.isConnected()) {
      Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
      mGoogleApiClient.disconnect();
    }

    showSignedOutUI();
  }
 public void signOutFromGplus() {
   if (mGoogleApiClient.isConnected()) {
     Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
     mGoogleApiClient.disconnect();
     mGoogleApiClient.connect();
     updateUI(false);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LoginActivity.mGoogleApiClient.registerConnectionCallbacks(this);

    Plus.AccountApi.revokeAccessAndDisconnect(LoginActivity.mGoogleApiClient);
  }
  /**
   * onConnected is called when our Activity successfully connects to Google Play services.
   * onConnected indicates that an account was selected on the device, that the selected account has
   * granted any requested permissions to our app and that we were able to establish a service
   * connection to Google Play services.
   */
  @Override
  public void onConnected(Bundle connectionHint) {
    final Person user = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);

    // The new cordova permission API's are available since Cordova-Android 5,
    // so if you're using API level 23 and want to deploy to Android 6,
    // make sure you're building with Cordova-Android 5 or higher.
    // .. it was either this or adding an Android Support library.
    try {
      Method hasPermissionMethod = cordova.getClass().getMethod("hasPermission", String.class);
      if (hasPermissionMethod != null) {
        if (!(Boolean) hasPermissionMethod.invoke(cordova, Manifest.permission.GET_ACCOUNTS)) {
          Method requestPermissionMethod =
              cordova
                  .getClass()
                  .getMethod("requestPermission", CordovaPlugin.class, int.class, String.class);
          requestPermissionMethod.invoke(
              cordova, this, REQUEST_GET_ACCOUNTS, Manifest.permission.GET_ACCOUNTS);
        }
      }
    } catch (Exception ignore) {
    }

    this.email = Plus.AccountApi.getAccountName(mGoogleApiClient);
    this.result = new JSONObject();

    try {
      result.put("email", email);
      // in case there was no internet connection, this may be null
      if (user != null) {
        result.put("userId", user.getId());
        result.put("displayName", user.getDisplayName());
        result.put("gender", getGender(user.getGender()));
        if (user.getImage() != null) {
          result.put("imageUrl", user.getImage().getUrl());
        }
        if (user.getName() != null) {
          result.put("givenName", user.getName().getGivenName());
          result.put("middleName", user.getName().getMiddleName());
          result.put("familyName", user.getName().getFamilyName());
          if (user.hasAgeRange()) {
            if (user.getAgeRange().hasMin()) {
              result.put("ageRangeMin", user.getAgeRange().getMin());
            }
            if (user.getAgeRange().hasMax()) {
              result.put("ageRangeMax", user.getAgeRange().getMax());
            }
          }
          if (user.hasBirthday()) {
            result.put("birthday", user.getBirthday());
          }
        }
      }
      resolveToken(email, result);
    } catch (JSONException e) {
      savedCallbackContext.error("result parsing trouble, error: " + e.getMessage());
    }
  }
 /** Sign-out from google */
 private void signOutFromGplus() {
   if (mGoogleApiClient.isConnected()) {
     Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
     mGoogleApiClient.disconnect();
     // mGoogleApiClient.connect();
     // updateUI(false);
     SensingController.unregisterAlarm(getApplicationContext());
   }
 }
Beispiel #18
0
  public void disconnect() {

    if (!isConnected() && !isConnecting()) return;

    Plus.AccountApi.clearDefaultAccount(getClient());
    getClient().disconnect();
    connected = false;
    clearAndOnUiThreadTriggerOnConnectListeners(false, -1);
  }
 /** Sign-out from google */
 private void signOutFromGplus() {
   Log.d(TAG, "signOutFromGplus!");
   if (mGoogleApiClient.isConnected()) {
     Log.d(TAG, "signOutFromGplus is connected then disconnecting!");
     Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
     mGoogleApiClient.disconnect();
     mGoogleApiClient.connect();
   }
 }
Beispiel #20
0
  // [START on_sign_out_clicked]
  private void onSignOutClicked() {
    // Clear the default account so that GoogleApiClient will not automatically
    // connect in the future.
    if (mGoogleApiClient.isConnected()) {
      Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
      mGoogleApiClient.disconnect();
    }

    showSignedOutUI();
  }
  @Override
  public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext)
      throws JSONException {
    this.savedCallbackContext = callbackContext;

    if (args.optJSONObject(0) != null) {
      JSONObject obj = args.getJSONObject(0);
      this.webKey = obj.optString(ARGUMENT_WEB_KEY, null);
      this.apiKey = obj.optString(ARGUMENT_ANDROID_KEY, null);
      this.requestOfflineToken = obj.optBoolean(ARGUMENT_OFFLINE_KEY, false);
      this.setupScopes(obj.optString(ARGUMENT_SCOPES, null));
      // possible scope change, so force a rebuild of the client
      this.mGoogleApiClient = null;
    }

    // It's important that we build the GoogleApiClient after setting up scopes so we know which
    // scopes to request when setting up the google services api client.
    buildGoogleApiClient();

    if (ACTION_IS_AVAILABLE.equals(action)) {
      final boolean avail =
          GooglePlayServicesUtil.isGooglePlayServicesAvailable(
                  this.cordova.getActivity().getApplicationContext())
              == 0;
      savedCallbackContext.success("" + avail);

    } else if (ACTION_LOGIN.equals(action)) {
      this.trySilentLogin = false;
      mGoogleApiClient.reconnect();

    } else if (ACTION_TRY_SILENT_LOGIN.equals(action)) {
      this.trySilentLogin = true;
      mGoogleApiClient.reconnect();

    } else if (ACTION_LOGOUT.equals(action)) {
      try {
        Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
        mGoogleApiClient.disconnect();
        // needed in onActivityResult when the connect method below comes back
        loggingOut = true;
        buildGoogleApiClient();
        mGoogleApiClient.connect();
      } catch (IllegalStateException ignore) {
      }
      savedCallbackContext.success("logged out");

    } else if (ACTION_DISCONNECT.equals(action)) {
      disconnect();
    } else {
      return false;
    }
    return true;
  }
  /** * Fetching user's information name, email, profile pic * */
  private void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        String personName = currentPerson.getDisplayName();
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
        Log.e(
            TAG,
            "Name: "
                + personName
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + personPhotoUrl);

        Toast.makeText(
                getApplicationContext(),
                "Signed In as:" + currentPerson.getDisplayName(),
                Toast.LENGTH_LONG)
            .show();
        if (!sharedPref.contains("UID")) {
          int Applicationid = getUID();
          saveSharedint("UID", Applicationid);
        }

        long DS = getDataValue(context);
        long DC = getFolderSize() + DS;
        String DataS = l2bytes(DS, false);
        String DataC = l2bytes(DC, false);

        long hours = CommonUtils.totaltime / 3600;
        long minutes = (CommonUtils.totaltime % 3600) / 60;
        long seconds = (long) ((CommonUtils.totaltime % 3600) % 60);

        txtDatasent.setText("Data Sent :" + DataS);
        txtDatasent.setAnimation(null);

      } else {
        Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 private void disconnect() {
   try {
     Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient)
         .setResultCallback(
             new ResultCallback<Status>() {
               @Override
               public void onResult(Status status) {
                 // mGoogleApiClient is now disconnected and access has been revoked.
                 // Don't care if it was disconnected already (status != success).
                 buildGoogleApiClient();
                 savedCallbackContext.success("disconnected");
               }
             });
   } catch (IllegalStateException e) {
     savedCallbackContext.success("disconnected");
   }
 }
  public static String getAuthToken(Context context) {
    if (!mGoogleApiClient.isConnected()) {
      mGoogleApiClient.connect();
    }
    String accountName = Plus.AccountApi.getAccountName(mGoogleApiClient);
    Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    String scopes = "audience:server:client_id:" + SERVER_CLIENT_ID; // Not the app's client ID.

    try {
      return GoogleAuthUtil.getToken(context, account, scopes);
    } catch (IOException e) {
      Log.e(TAG, "Error retrieving ID token.", e);
      return null;
    } catch (GoogleAuthException e) {
      Log.e(TAG, "Error retrieving ID token.", e);
      return null;
    }
  }
  public boolean requestlogout() {
    Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
    String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
    String response = null;
    try {

      JSONObject userData = new JSONObject();
      userData.put("email", email);
      Log.d(TAG, userData.toString());
      response = CommonFunctions.sendRequestToServer(userData.toString(), "logout");
      if (response.contains("DONE")) {
        return true;
      }

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return false;
  }
  private void handleSignInSuccess() {
    Person currentPerson = Plus.PeopleApi.getCurrentPerson(this.googleApiClient);
    if (currentPerson != null) {
      User user = new User();
      user.setName(currentPerson.getName().getGivenName());
      user.setSurname(currentPerson.getName().getFamilyName());
      user.setAuthenticationType(AuthenticationType.Google);

      String photoUrl = currentPerson.getImage().getUrl();
      photoUrl = photoUrl.replace("?sz=50", "?sz=100");
      user.setPhotoUrl(photoUrl);

      String email = Plus.AccountApi.getAccountName(this.googleApiClient);
      user.setEmail(email);

      // We took necessary the google account information, now we save the user into our database
      // with an id
      // The authentication service will handle the rest (operation success and failure situations)
      this.authenticationServiceProxy.saveUser(user);
    }
  }
  @Override
  public void onConnected(Bundle bundle) {
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
      BrewSharedPrefs.setIsUserLoggedIn(true);
      Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
      BrewSharedPrefs.setFullName(currentPerson.getDisplayName());
      String personPhoto = currentPerson.getImage().getUrl();

      try {
        URL url = new URL(personPhoto);
        personPhoto = personPhoto.replace(url.getQuery(), "");
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }

      BrewSharedPrefs.setGoolgePlusProfileUrl(currentPerson.getUrl());
      BrewSharedPrefs.setUserProfileImageUrl(personPhoto);
      BrewSharedPrefs.setEmailAddress(Plus.AccountApi.getAccountName(mGoogleApiClient));
      PlusAccountSetup();
    }
  }
  private void showSignedInUI() {
    // set current user
    String accountName = Plus.AccountApi.getAccountName(mGoogleApiClient);
    Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    User.setCurrentUser(new User(account.name, account.name, "0", "0"));

    // Send Authentication Token to server and set current User
    new GetUserIDTask().execute();

    setContentView(R.layout.activity_myrides);
    if (savedInstanceState == null) {
      activityFragment = new MyRidesFragment();
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.container, (activityFragment))
          .commit();
    }

    signedIn = true;
    invalidateOptionsMenu();
  }
  /** Fetching user's information name, email, profile picture */
  private void getGGProfileInformation() {
    Log.e(tag, "getGGProfileInformation");
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        String personGooglePlusProfile = currentPerson.getUrl();

        Log.e(tag, currentPerson.toString());

        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
        String id = currentPerson.getId();
        String name = new String(currentPerson.getDisplayName().getBytes("UTF-8"), "UTF-8");
        String birthday = "";
        if (currentPerson.getBirthday() != null) {
          birthday = currentPerson.getBirthday();
        }
        String gender = currentPerson.getGender() == 1 ? "men" : "women";
        String avatar = currentPerson.getImage().getUrl();
        Log.e(
            tag,
            "Name: "
                + name
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + avatar
                + ", birthday: "
                + birthday);

        new GGLoginTask().execute(name, email, avatar, gender, birthday, id);
      } else {
        Log.e(tag, "Person information is null");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void getProfileInformation() {
    try {
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        String personName = currentPerson.getDisplayName();
        String personPhotoUrl = currentPerson.getImage().getUrl();
        String personGooglePlusProfile = currentPerson.getUrl();
        String email = Plus.AccountApi.getAccountName(mGoogleApiClient);

        Log.e(
            TAG,
            "Name: "
                + personName
                + ", plusProfile: "
                + personGooglePlusProfile
                + ", email: "
                + email
                + ", Image: "
                + personPhotoUrl);

        profileName.setText(personName);
        profileEmail.setText(email);

        // by default the profile url gives 50x50 px image only
        // we can replace the value with whatever dimension we want by
        // replacing sz=X
        personPhotoUrl =
            personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE;

        new LoadProfileImage(imgProfilePic).execute(personPhotoUrl);

      } else {
        Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }