Mateusz Kaflowski
Mateusz Kaflowski

Reputation: 2367

Always gray +1 button on activity in Android

I just have added +1 google to my button but it is always gray after initialize() and cannot do anything with that:

enter image description here

My code looks like this:

public class Stars extends Activity implements ConnectionCallbacks,
        OnConnectionFailedListener {

    private PlusClient mPlusClient;
    PlusOneButton mPlusOneButton;

    private static final int PLUS_ONE_REQUEST_CODE = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);


            setContentView(R.layout.stars);

            // g+1------------------------------------------------------
            mPlusClient = new PlusClient.Builder(this, this, this)
                    .setVisibleActivities(
                            "http://schemas.google.com/AddActivity",
                            "http://schemas.google.com/BuyActivity").build();

            mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);

            // ---------------------------------------------------------



    }

    @Override
    protected void onStart() {
        super.onStart();
        mPlusClient.connect();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mPlusClient.disconnect();
    }

    @Override
    protected void onResume() {

        mPlusOneButton.initialize(mPlusClient,
                "https://developers.google.com/+", PLUS_ONE_REQUEST_CODE);

        super.onResume();
    }

    public void onConnectionFailed(ConnectionResult status) {
        // Nothing to do.
    }

    public void onDisconnected() {
        // Nothing to do.
    }

    public void onConnected(Bundle arg0) {
        // TODO Auto-generated method stub

    }
}

How to repair that and where are info in my code about that what I registered in google api console?

Upvotes: 0

Views: 188

Answers (1)

Ian Barber
Ian Barber

Reputation: 19960

Try calling .clearScopes() on the builder, rather than setting it up for Sign-In as you have it at the moment. You don't need to connect() or disconnect() it in that case either.

mPlusClient = new PlusClient(this, this, this)
    .clearScopes()
    .build();

Currently its associated with a PlusClient setup to be used for sign-in, but the user hasn't signed in, hence the greying out.

Upvotes: 3

Related Questions