Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.argon.schoolplies;
- import android.content.Intent;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import com.google.android.gms.auth.api.signin.GoogleSignIn;
- import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
- public class loginActivity extends AppCompatActivity implements View.OnClickListener{
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- // Configure sign-in to request the user's ID, email address, and basic
- // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
- GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
- .requestEmail()
- .build();
- // Build a GoogleSignInClient with the options specified by gso.
- mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
- Button gButton = findViewById(R.id.sign_in_button);
- gButton.setOnClickListener(this);
- }
- @Override
- public void onClick(View v){
- switch (v.getId()) {
- case R.id.sign_in_button:
- signIn();
- break;
- // ...
- }
- }
- private void signIn() {
- Intent signInIntent = mGoogleSignInClient.getSignInIntent();
- startActivityForResult(signInIntent, RC_SIGN_IN);
- }
- //end of main class
- }
Advertisement
Add Comment
Please, Sign In to add comment