Exemplo n.º 1
0
 @Override
 public void onStop() {
   super.onStop();
   if (mGoogleApiClient.isConnected()) {
     mGoogleApiClient.disconnect();
   }
 }
Exemplo n.º 2
0
  @Override
  public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr =
        Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {

      Log.d(TAG, "Got cached sign-in"); /*
            GoogleSignInResult result = opr.get();
            handleSignInResult(result);*/

      Intent dashbIntent = new Intent(this, ProfileActivity.class);
      dashbIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
      startActivity(dashbIntent);

    } else {
      // If the user has not previously signed in on this device or the sign-in has expired,
      // this asynchronous branch will attempt to sign in the user silently.  Cross-device
      // single sign-on will occur in this branch.
      //            showProgressDialog();
      /*opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                      @Override
                      public void onResult(GoogleSignInResult googleSignInResult) {
      //                    hideProgressDialog();
                          handleSignInResult(googleSignInResult);
                      }
                  });*/
    }
  }
Exemplo n.º 3
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
      GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
      handleSignInResult(result);
    } else {
      //        Toast.makeText(this, "An Error Occured, Check your Network Connection
      // Settings",Toast.LENGTH_SHORT).show();
      //        btEnter.setVisibility(View.GONE);
      //        btnSignIn.setVisibility(View.VISIBLE);
    }
  }
Exemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    btnSignIn = (Button) findViewById(R.id.btn_sign_in);
    //        btnSignOut = (Button) findViewById(R.id.btn_sign_out);
    //        btnRevokeAccess = (Button) findViewById(R.id.btn_revoke_access);
    imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic);
    g_icon = (ImageView) findViewById(R.id.google_icon);
    txtName = (TextView) findViewById(R.id.txtName);
    txtEmail = (TextView) findViewById(R.id.txtEmail);
    title = (TextView) findViewById(R.id.title_text);
    llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);
    llWelcome = (LinearLayout) findViewById(R.id.llWelcomeIC);
    llField = (LinearLayout) findViewById(R.id.llField);
    etPhone = (EditText) findViewById(R.id.etPhone);
    etName = (EditText) findViewById(R.id.etName_login);
    //        buttonContainer = (LinearLayout) findViewById(R.id.button_container);
    btEnter = (CircularProgressButton) findViewById(R.id.btn_enter);
    btEnter.setIndeterminateProgressMode(true);

    // Button click listeners
    btnSignIn.setOnClickListener(this);

    GoogleSignInOptions gso =
        new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();

    mGoogleApiClient =
        new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    // [END build_client]

  }