我刚刚在我的按钮上添加了+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控制台中注册的信息?
答案 0 :(得分:3)
尝试在构建器上调用.clearScopes(),而不是像现在一样为登录设置它。在这种情况下,您不需要连接()或断开()。
mPlusClient = new PlusClient(this, this, this)
.clearScopes()
.build();
目前,它与用于登录的PlusClient设置相关联,但用户尚未登录,因此灰显。