0

我刚刚在我的按钮上添加了 +1 google,但它在 initialize() 之后总是灰色的,并且无法对此做任何事情:

在此处输入图像描述

我的代码如下所示:

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

    }
}

如何修复它,我的代码中关于我在 google api 控制台中注册的信息在哪里?

4

1 回答 1

3

尝试在构建器上调用 .clearScopes() ,而不是像现在那样为登录设置它。在这种情况下,您也不需要 connect() 或 disconnect() 它。

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

目前它与用于登录的 PlusClient 设置相关联,但用户尚未登录,因此显示为灰色。

于 2013-09-05T13:30:09.003 回答