问题
I followed this link to use the +1 button in my Android application to +1 a link or a website, but unfortunately it didn't work as expected and it didn't respond when I click on it. I tried to use the following:
mPlusOneButton.setOnPlusOneClickListener(new OnPlusOneClickListener() {
@Override
public void onPlusOneClick(Intent arg0) {
// TODO Auto-generated method stub
startActivityForResult(arg0, 0);
}
});
But also no response. As an example I tried to use the following line of code:
mPlusOneButton.initialize(plusClient, "http://www.googleplustoday.net", PLUS_ONE_REQUEST_CODE);
And there is no effect on my Google plus profile at the +1 tab.
Who can help? Thanks in advance.
回答1:
Make sure to be connected to Google Plus:
mPlusOneButton.setOnPlusOneClickListener(new OnPlusOneClickListener() {
@Override
public void onPlusOneClick(Intent intent) {
if(!plusClient.isConnected()) {
plusClient.connect();
} else {
startActivityForResult(intent, 0);
}
}
}
回答2:
Be sure that you initialize your mPlusOneButton
prior to handling clicks such as in the onResume
method. When I tested by not initializing before the click then I could get it to fail.
In the androidsdk/extras/google/google_play_services/samples/plus/src/com/google/android/gms/samples/plus/PlusOneActivity.java
contains a skeleton activity for getting the PlusOne button working.
If you can post your full activity code and any applicable errors from logcat that would help further identify the issue.
来源:https://stackoverflow.com/questions/15540965/1-click-is-not-working-in-android-integration-with-google