Ejemplo n.º 1
0
  /*
   * 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) {
    // Reaching onConnected means we consider the user signed in.
    Timber.i(TAG, "onConnected");

    // Update the user interface to reflect that the user is signed in.
    mSignInButton.setEnabled(false);
    mSignOutButton.setEnabled(true);
    mRevokeButton.setEnabled(true);

    // Retrieve some profile information to personalize our app for the
    // user.
    Person currentUser = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);

    Timber.i("UserInfo[" + currentUser.toString() + "]");
    Timber.i("ImageUrl[" + currentUser.getImage().getUrl() + "]");

    // mStatus.setText(String.format(getResources().getString(R.string.signed_in_as),
    // currentUser.getDisplayName()));
    // Plus.PeopleApi.loadVisible(mGoogleApiClient,
    // null).setResultCallback(this);

    // Indicate that the sign in process is complete.
    mSignInProgress = STATE_DEFAULT;

    // on successful login move to wall feed activity
    startActivity(new Intent(this, WallFeedActivity.class));
    // startActivity(new Intent(this, DummyActivity.class));
    // startActivity(new Intent(this, NewPictureActivity.class));
    LoginActivity.this.finish();
  }
Ejemplo n.º 2
0
  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();
    }
  }
Ejemplo n.º 3
0
  /** 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();
    }
  }