title: Integrating Google Sign in button in Android App
body: <p>Okay i was trying this code from Google <a href="https://developers.google.com/identity/sign-in/android/sign-in?configured=true" rel="nofollow noreferrer">https://developers.google.com/identity/sign-in/android/sign-in?configured=true</a></p>
  
  <p>LoginActivity</p>
  
  <pre><code>GoogleApiClient mGoogleApiClient;
  GoogleSignInOptions gso;
  SignInButton signIn_btn;
  private static final int RC_SIGN_IN = 0;
  ProgressDialog progress_dialog;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  
      buidNewGoogleApiClient();
      setContentView(R.layout.activity_login);
      customizeSignBtn();
      setBtnClickListeners();
  
  
      mNotificationManager = (NotificationManager) this.getApplicationContext().getSystemService(this.NOTIFICATION_SERVICE);
  
      Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "Big Daddy St.ttf");
      Typeface myTypeFaceFacebook = Typeface.createFromAsset(getAssets(), "Big Daddy St.ttf");
  
  
      mainImage = (ImageView) findViewById(R.id.imageView1);
  
      TextView textView1 = (TextView) findViewById(R.id.textView1);
      textView1.setOnClickListener(this);
      textView1.setTypeface(myTypeFace);
  
      Button button = (Button) findViewById(R.id.btn_login_facebook);
      button.setOnClickListener(this);
      button.setTypeface(myTypeFaceFacebook);
  
  
  
  }
  
  private void buidNewGoogleApiClient() {
  
      gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
              .requestEmail()
              .build();
      mGoogleApiClient = new GoogleApiClient.Builder(this)
              .enableAutoManage(this, this)
              .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
              .build();
  }
  
  private void customizeSignBtn() {
  
      signIn_btn = (SignInButton) findViewById(R.id.sign_in_button);
      signIn_btn.setSize(SignInButton.SIZE_STANDARD);
      signIn_btn.setScopes(gso.getScopeArray());
  
  }
  
  private void setBtnClickListeners() {
      // Button listeners
      signIn_btn.setOnClickListener(this);
  
  
  }
  
  protected void onStart() {
      super.onStart();
      mGoogleApiClient.connect();
  }
  
  protected void onStop() {
      super.onStop();
      if (mGoogleApiClient.isConnected()) {
          mGoogleApiClient.disconnect();
      }
  }
  
  @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) {
          if (resultCode != RESULT_OK) {
  
  
  
          }
          GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
          getSignInResult(result);
      }
  }
  
  private void getSignInResult(GoogleSignInResult result) {
  GoogleSignInStatusCodes.getStatusCodeString(result.getStatus().getStatusCode());
  
  
      if (result.isSuccess()) {
  
          // Signed in successfully, show authenticated UI.
          GoogleSignInAccount acct = result.getSignInAccount();
          Toast.makeText(this, "email: " + acct.getEmail(), Toast.LENGTH_SHORT).show();
  
          //TextView user_name= (TextView)findViewById(R.id.userName);
          // TextView email_id= (TextView)findViewById(R.id.emailId);
          // user_name.setText("UserName: "+ acct.getDisplayName());
          // email_id.setText("Email Id: " + acct.getEmail());
  
          progress_dialog.dismiss();
      } else {
          // Signed out, show unauthenticated UI.
          try {
  
  
          } catch (Exception e) {
              Toast.makeText(this, "Exception: " +e.getMessage(), Toast.LENGTH_LONG).show();
          }
  
          //updateUI(false);
      }
  }
  
  
  
  
  
  
  @Override
  public void onClick(View view) {
  
  
  
  
      if(view.getId() == R.id.textView1){
          Intent signupIntent = new Intent(this, SignUpScreen.class);
          startActivity(signupIntent);
  
      }
  
      if(view.getId() == R.id.btn_login_facebook){
          Intent intent = new Intent(this, todelete.class);
  
          //Notification
          // notificationWithButton();
          startActivity(intent);
      }
      if(view.getId()==R.id.sign_in_button){
          Toast.makeText(this, "start sign process", Toast.LENGTH_SHORT).show();
          gSignIn();
  
  
      }
  
  }
  private void gSignIn() {
      Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
      startActivityForResult(signInIntent, RC_SIGN_IN);
    //  progress_dialog.show();
  }
  
  
  void notificationWithButton(){
      if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN) {
          // Prepare intent which is triggered if the  notification button is pressed
          Intent intent = new Intent(this, MainActivity.class);
          PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
  
          // Building the notifcation
          NotificationCompat.Builder nBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
                  .setSmallIcon(R.mipmap.ic_launcher) // notification icon
                  .setContentTitle("Button notification") // notification title
                  .setContentText("Expand to show the buttons...") // content text
                  .setTicker("Showing button notification") // status bar message
                  .addAction(R.drawable.common_google_signin_btn_icon_dark, "Accept", pIntent) // accept notification button
                  .addAction(R.drawable.common_google_signin_btn_icon_dark_normal, "Cancel", pIntent); // cancel notification button
  
          mNotificationManager.notify(1001, nBuilder.build());
  
      } else {
          Toast.makeText(this, "You need a higher version", Toast.LENGTH_LONG).show();
      }
  }
  
  
  @Override
  public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
  
  }
  
  }
  </code></pre>
  
  <p>Manifest.xml</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;!-- To access accounts configured on device --&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;!-- To use account credentials --&gt;
      &lt;uses-permission android:name="android.permission.USE_CREDENTIALS" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.WIFI" /&gt;
      &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
  
      &lt;meta-data
          android:name="com.google.android.geo.API_KEY"
          android:value="@string/google_maps_key" /&gt;
      &lt;meta-data
          android:name="com.google.android.gms.version"
          android:value="@integer/google_play_services_version"
  </code></pre>
  
  <p>/></p>
  
  <p>build.gradle (Project)</p>
  
  <pre><code>  dependencies {
      classpath 'com.android.tools.build:gradle:2.1.3'
      classpath 'com.google.gms:google-services:3.0.0'
  </code></pre>
  
  <p>build.gradle (App)</p>
  
  <pre><code>compile 'com.android.support:appcompat-v7:24.2.1'
  compile 'com.jakewharton:butterknife:8.1.0'
  compile 'com.google.android.gms:play-services-auth:9.6.1'
  compile 'com.google.android.gms:play-services:9.6.1'
  compile 'com.android.support:support-v4:24.2.1'
  }
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p>Your help will be much appreciated.</p>
  
  <p>Edit: Added         GoogleSignInStatusCodes.getStatusCodeString(result.getStatus().getStatusCode());
   which returns 10, corresponding to DEVELOPER_ERROR. </p>
  
  <p>I had previously created a key for Google Maps, which is included in my Project (In Manifest file, meta tags), now do I have to create another Key? If yes, how do I include it? </p>