title: Google+ API Activity to Fragment
body: <p>I'm having trouble with converting my code to fragment</p>
  
  <p>this is my code when my app is still an activity</p>
  
  <pre><code>package com.ronnielp.loginsample2;
  
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.Scopes;
  import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
  import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
  import com.google.android.gms.plus.PlusClient;
  import com.google.android.gms.plus.model.people.Person;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.content.IntentSender.SendIntentException;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.TextView;
  
  public class SignIn extends Activity implements OnClickListener, 
      ConnectionCallbacks, OnConnectionFailedListener{
  
  
      private static final int REQUEST_CODE_RESOLVE_ERR = 40;
      private PlusClient mPlusClient;
      private ConnectionResult mConnectionResult;
      private TextView txtUser;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mPlusClient =new PlusClient.Builder(this, this, this)
          .setScopes(Scopes.PLUS_LOGIN)
          .setVisibleActivities("http://schemas.google.com/AddActivity")
          .build();
  
          findViewById(R.id.sign_in_button).setOnClickListener(this);
          txtUser = (TextView) findViewById(R.id.txtUser);
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  
  
      @Override
      protected void onStart() {
          // TODO Auto-generated method stub
          super.onStart();
          mPlusClient.connect();
      }
  
      @Override
      protected void onStop() {
          // TODO Auto-generated method stub
          super.onStop();
          mPlusClient.disconnect();
      }
  
      @Override
      public void onConnectionFailed(ConnectionResult result) {
          // TODO Auto-generated method stub
          mConnectionResult = result;
      }
  
      @Override
      public void onConnected(Bundle connectionHint) {
          // TODO Auto-generated method stub
          Person user = mPlusClient.getCurrentPerson();
          String acc = mPlusClient.getAccountName();
          txtUser.setText(acc);
      }
  
      @Override
      public void onDisconnected() {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onClick(View view) {
          // TODO Auto-generated method stub
          if (view.getId() == R.id.sign_in_button &amp;&amp;  !mPlusClient.isConnected() &amp;&amp; mConnectionResult !=null){
              try{
                  mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
              } catch (SendIntentException e){
                  mConnectionResult = null;
                  mPlusClient.connect();
              }
          }
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          // TODO Auto-generated method stub
          if (requestCode == REQUEST_CODE_RESOLVE_ERR &amp;&amp; resultCode == RESULT_OK){
              mConnectionResult = null;
              mPlusClient.connect();
          }
      }
  
  
  }
  </code></pre>
  
  <p>and when i convert it to fragment my code doesnt work anymore
  please help me I'm still a newbie in Android programming</p>