我在執行我的Android應用程序中的Google +1
按鈕時遇到問題。 我按照這個link指示,我的活動顯示g+
按鈕成功,但點擊按鈕後,它只顯示按鈕上的進度條,請告訴我如何在Android的+1按鈕工作,它應該打開登錄互聯網或什麼? 我沒有在我的應用程序中使用Google的+1按鈕實現登錄。這裏是我的代碼,這是我的代碼的一部分,所以它是不正確的。如何在Android應用程序中添加Google +1按鈕
public class as {
private static final String URL = "www.app.in";
private static final int PLUS_ONE_REQUEST_CODE = 10;
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
private PlusOneButton mPlusOneButton;
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.product_details);
setCurrentContext(this);
super.onCreate(savedInstanceState);
mPlusOneButton = (PlusOneButton) findViewById(R.id.googleplus);
mPlusClient = new PlusClient.Builder(this, this, this).clearScopes()
.build();
}
@Override
protected void onStart() {
super.onStart();
Log.d(TAG, "OnStart");
mPlusClient.connect();
}
@Override
protected void onStop() {
super.onStop();
Log.d(TAG, "onStop");
mPlusClient.disconnect();
}
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.d(TAG, "onConnectionFailed");
if (mConnectionProgressDialog.isShowing()) {
// The user clicked the sign-in button already. Start to resolve
// connection errors. Wait until onConnected() to dismiss the
// connection dialog.
if (result.hasResolution()) {
try {
result.startResolutionForResult(this,
REQUEST_CODE_RESOLVE_ERR);
} catch (SendIntentException e) {
mPlusClient.connect();
}
}
}
// Save the result and resolve the connection failure upon a user click.
mConnectionResult = result;
}
@Override
protected void onActivityResult(int requestCode, int responseCode,
Intent intent) {
Log.d(TAG, "onActivityResult");
if (requestCode == REQUEST_CODE_RESOLVE_ERR
&& responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
}
@Override
public void onConnected(Bundle connectionHint) {
// String accountName = mPlusClient.getAccountName();
// Toast.makeText(this, accountName + " is connected.",
// Toast.LENGTH_LONG)
// .show();
Log.d(TAG, "onConnected");
}
@Override
public void onDisconnected() {
Log.d(TAG, "disconnected");
}
}
嗨,我有同樣的問題,你有沒有發現一個解決方案? –