Didn't jump to "super.onPostCreate ()" when using Google Play Services API

To enable Google+ for Android. I have to use the Google Play Services API. I am using the exact code from this article on the G + sign in . However. Each time this is done I am redirected from my OnClickListener and GoogleAPIClientBuilder to a Play Service class called ActivityThread.

In the ActivityThread, the code I'm landing on is:

 if (!activity.mCalled) {
       throw new SuperNotCalledException(
        "Activity " + r.intent.getComponent().toShortString() +
        " did not call through to super.onPostCreate()");
}

      

I tried to change the code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btnSignIn = (SignInButton) findViewById(R.id.btn_sign_in);
    btnSignOut = (Button) findViewById(R.id.btn_sign_out);
    btnRevokeAccess = (Button) findViewById(R.id.btn_revoke_access);
    imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic);
    txtName = (TextView) findViewById(R.id.txtName);
    txtEmail = (TextView) findViewById(R.id.txtEmail);
    llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);

    // Button click listeners
    btnSignIn.setOnClickListener(this);
    btnSignOut.setOnClickListener(this);
    btnRevokeAccess.setOnClickListener(this);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API, null)
            .addScope(Plus.SCOPE_PLUS_LOGIN).build();
}

      

in

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btnSignIn = (SignInButton) findViewById(R.id.btn_sign_in);
    btnSignOut = (Button) findViewById(R.id.btn_sign_out);
    btnRevokeAccess = (Button) findViewById(R.id.btn_revoke_access);
    imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic);
    txtName = (TextView) findViewById(R.id.txtName);
    txtEmail = (TextView) findViewById(R.id.txtEmail);
    llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);

}

@Override
protected void onPostCreate(Bundle savedInstanceState){

    super.onPostCreate(savedInstanceState);

    // Button click listeners
    btnSignIn.setOnClickListener(this);
    btnSignOut.setOnClickListener(this);
    btnRevokeAccess.setOnClickListener(this);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API, null)
            .addScope(Plus.SCOPE_PLUS_LOGIN).build();
}

      

This change made no difference and the activity was still posted to the same "did not go to the super.onPostCreate ()" section.

This doesn't seem to only affect OnCreate, but anytime Google Play Services is used throughout this activity.

I'm not sure why this is happening, is it a problem with the way I added Google Play Services, or should I be using a different code?

+3


source to share





All Articles