title: Adding a google sign in button - sign in problems
body: <p>I am trying to put google sign in button in my android app.
  I have take reference from <a href="https://developers.google.com/+/mobile/android/sign-in" rel="nofollow noreferrer">https://developers.google.com/+/mobile/android/sign-in</a> and it showing me continuous progress bar and doesn't log into my account.
  I have already added my id on emulator.
  I am attaching the image of it.
  And here is my code.</p>
  
  <pre><code>public class MyActivity extends Activity implements GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, View.OnClickListener {
  
      private static final String TAG = "ExampleActivity";
      private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
  
      private ProgressDialog mConnectionProgressDialog;
      private PlusClient mPlusClient;
      private ConnectionResult mConnectionResult;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          mPlusClient = new PlusClient.Builder(this, this, this)
                  .setActions("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity")
                  .build();
          findViewById(R.id.sign_in_button).setOnClickListener(this);
          mConnectionProgressDialog = new ProgressDialog(this);
          mConnectionProgressDialog.setMessage("Signing in...");
      }
  
  
      @Override
      public void onConnected(Bundle bundle) {
          // We've resolved any connection errors.
          mConnectionProgressDialog.dismiss();
          Toast.makeText(this, " User is connected.", Toast.LENGTH_LONG).show();
      }
  
      @Override
      public void onDisconnected() {
          Log.d(TAG, "disconnected");
      }
  
      @Override
      public void onConnectionFailed(ConnectionResult connectionResult) {
          if (mConnectionProgressDialog.isShowing()) {
              // The user clicked the sign-in button already. Start to resolve
              // connection errors. Wait until onConnected() to dismiss the
              // connection dialog.
              if (connectionResult.hasResolution()) {
                  try {
                      connectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                  } catch (IntentSender.SendIntentException e) {
                      mPlusClient.connect();
                  }
              }
          }
  
          // Save the intent so that we can start an activity when the user clicks
          // the sign-in button.
          mConnectionResult = connectionResult;
      }
  
      @Override
      public void onClick(View view) {
          if (view.getId() == R.id.sign_in_button &amp;&amp; !mPlusClient.isConnected()) {
              if (mConnectionResult == null) {
                  mConnectionProgressDialog.show();
              } else {
                  try {
                      mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                  } catch (IntentSender.SendIntentException e) {
                      // Try connecting again.
                      mConnectionResult = null;
                      mPlusClient.connect();
                  }
              }
          }
      }
  
      @Override
      protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
          if (requestCode == REQUEST_CODE_RESOLVE_ERR &amp;&amp; responseCode == RESULT_OK) {
              mConnectionResult = null;
              mPlusClient.connect();
          }
      }
  }
  </code></pre>
  
  <p>main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"&gt;
  
  
      &lt;com.google.android.gms.common.SignInButton
              android:id="@+id/sign_in_button"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_centerVertical="true"
              android:layout_centerHorizontal="true"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>androidmanifest.xml</p>
  
  <pre><code>![&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.example.GooglePlusDemo"
            android:versionCode="1"
            android:versionName="1.0"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS"/&gt;
      &lt;uses-permission android:name="android.permission.USE_CREDENTIALS"/&gt;
  
  
      &lt;application
              android:label="@string/app_name"
              android:icon="@drawable/ic_launcher"&gt;
          &lt;meta-data
                  android:name="com.google.android.gms.version"
                  android:value="@integer/google_play_services_version"/&gt;
          &lt;activity
                  android:name="MyActivity"
                  android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"/&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
              &lt;/intent-filter&gt;
  
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;]
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Flyft.jpg" alt="enter image description here"></p>
  
  <p>Even after turn on google api in console it shows me error 
  and google+ app is already installed on my device.
  i am posting both images.</p>
  
  <p><img src="https://i.stack.imgur.com/tbdXj.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/viqr6.jpg" alt="enter image description here"></p>