title: Google plus login activity with fragment
body: <p>Hello i have a problem to integrate the login google plus in my app. I call an Activity Login that deals with the integration with social networks. I have already integrated the code of the login of facebook and went to fruition, but when I try to integrate google plus I didn't succeed. The activity consists of a fragment and the error is here. I followed the official guidelines of google but to no avail. what can I do?</p>
  
  <blockquote>
    <p>public class LoginActivity extends Activity implements
    NavigationDrawerFragment.NavigationDrawerCallbacks, ConnectionCallbacks,
    OnConnectionFailedListener {</p>
  
  <pre><code>private NavigationDrawerFragment mNavigationDrawerFragment;
  
  //google plus
  private ProgressDialog mConnectionProgressDialog;
  private PlusClient mPlusClient;
  private ConnectionResult mConnectionResult;
  private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
  private static final String TAG = "LoginActivity";
  
  //facebook UiLifecycleHelper
  private UiLifecycleHelper uiHelper;
  
  //metodo callback facebook
  private Session.StatusCallback callback = new Session.StatusCallback() {
      @Override
      public void call(Session session, SessionState state, Exception exception) { 
      }
  };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_login);
  
      mNavigationDrawerFragment = (NavigationDrawerFragment)
              getFragmentManager().findFragmentById(R.id.navigation_drawer);
  
      // Set up the drawer.
      mNavigationDrawerFragment.setUp(
              R.id.navigation_drawer,
              (DrawerLayout) findViewById(R.id.drawer_layout));
  
      //facebook login
      uiHelper = new UiLifecycleHelper(this, callback);
      uiHelper.onCreate(savedInstanceState);
  
      //google plus
      mPlusClient =
            new PlusClient.Builder(this, this, this).setActions(
                "http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity")
                .setScopes("PLUS_LOGIN") // Space separated list of scopes
                .build();
  }
  
  @Override
  public void onNavigationDrawerItemSelected(int position) {
      // update the main content by replacing fragments
      FragmentManager fragmentManager = getFragmentManager();
      fragmentManager.beginTransaction()
              .replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
              .commit();
  }
  public void onSectionAttached(int number) {
  }
  
  public void restoreActionBar() {
      ActionBar actionBar = getActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
      actionBar.setDisplayShowTitleEnabled(true);
      actionBar.setTitle("Login/Logout");
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      if (!mNavigationDrawerFragment.isDrawerOpen()) {
          // Only show items in the action bar relevant to this screen
          // if the drawer is not showing. Otherwise, let the drawer
          // decide what to show in the action bar.
          getMenuInflater().inflate(R.menu.login, menu);
          restoreActionBar();
          return true;
      }
      return super.onCreateOptionsMenu(menu);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      return super.onOptionsItemSelected(item);
  }
  @Override
  public void onStart() {
      super.onStart();
  }
  @Override
  public void onStop() {
      super.onStop();
      //facebook
      uiHelper.onStop();
  }
  @Override
  public void onResume() {
      super.onResume();
      //facebook
      uiHelper.onResume();
  }
  
  @Override
  public void onPause() {
      super.onPause();
      //facebook
      uiHelper.onPause();
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      //facebook
      uiHelper.onActivityResult(requestCode, resultCode, data);
      //google plus
      if (requestCode == REQUEST_CODE_RESOLVE_ERR &amp;&amp; resultCode == RESULT_OK) {
          mConnectionResult = null;
          mPlusClient.connect();
      }
  }
  
  @Override
  public void onDestroy() {
      super.onDestroy();
      //facebook
      uiHelper.onDestroy();
  }
  
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      //facebook
      uiHelper.onSaveInstanceState(outState);
  }
  //********************FRAGMENT*****************************
  public static class PlaceholderFragment extends Fragment{
  
      private static final String ARG_SECTION_NUMBER = "section_number";
  
  
      public static PlaceholderFragment newInstance(int sectionNumber) {
          PlaceholderFragment fragment = new PlaceholderFragment();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      public PlaceholderFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
        String messaggioIniziale = "E' necessario registrarsi o effettuare il login tramite Facebook.&lt;BR&gt;&lt;BR&gt;";
          View rootView = inflater.inflate(R.layout.fragment_login, container, false);
          TextView textView = (TextView) rootView.findViewById(R.id.section_label);
          textView.setText(Html.fromHtml(messaggioIniziale));
  
          //login button facebook
          LoginButton buttonFacebook = (LoginButton) rootView.findViewById(R.id.authButton);
          buttonFacebook.setReadPermissions(Arrays.asList("public_profile","email"));            
          return rootView;
      }
  }     @Override   public void onConnectionFailed(ConnectionResult result) {       if (mConnectionProgressDialog.isShowing()) {
          // L'utente ha già fatto clic sul pulsante di accesso. Inizia a risolvere
          // gli errori di connessione. Attendi fino a onConnected() per eliminare la
          // finestra di dialogo di connessione.
          if (result.hasResolution()) {
                  try {
                          result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                  } catch (SendIntentException e) {
                          mPlusClient.connect();
                  }
          }
  }
  mConnectionResult = result;
        }
  </code></pre>
    
    <p>@Override<br>
    public void onConnected(Bundle connectionHint) {<br>
            mConnectionProgressDialog.dismiss();  }</p>
    
    <p>@Override<br>
    public void onDisconnected() {
            Log.d(TAG, "disconnected");   } 
    }</p>
  </blockquote>