我的Google+1按钮变灰并且无法使用?

4

我正在尝试在我的应用程序中集成G+按钮。 G+按钮变灰色了,并且没有计数。如何使其变为红色?

          public class HomeActivity extends SherlockActivity implements ConnectionCallbacks, OnConnectionFailedListener{

private static final String URL = "https://play.google.com/store/apps/details?id=com.phoneix.allu";
private static final int PLUS_ONE_REQUEST_CODE = 0;
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;

private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
private PlusOneButton mPlusOneStandardButton;

@Override
public void onCreate(Bundle pBundle) {
    super.onCreate(pBundle);
   setContentView(R.layout.dashboard);

    mPlusOneStandardButton = (PlusOneButton) findViewById(R.id.plus_one_standard_button);


    mPlusClient = new PlusClient.Builder(this, this, this)

            .build();


}

@Override
public void onDestroy() {
    if (adView != null) {
        adView.destroy();
    }
    super.onDestroy();
}
@Override
protected void onResume() {
    super.onResume();
    // Refresh the state of the +1 button each time we receive focus.

    mPlusOneStandardButton.initialize(URL, PLUS_ONE_REQUEST_CODE);

}

@Override
public void onDisconnected() {
    // Nothing to do.
}
@Override
public void onConnectionFailed(ConnectionResult result) {
       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 intent so that we can start an activity when the user clicks
       // the sign-in button.
       mConnectionResult = result;
}

public void onConnected(Bundle connectionHint) {
    mPlusOneStandardButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
        mConnectionResult = null;
        mPlusClient.connect();
    }
}

}


我的应用程序也出现了同样的问题,我也添加了G+,昨天和今天它也是灰色的。我认为这可能是Google Play服务遇到的问题。 - Nitin Misra
@NitinMisra 哦,好的,如果它开始工作了,请告诉我,如果我先知道了,我会通知您。 - Asthme
3个回答

0

问题出在 Google Play 服务的最新更新上。 一旦我从应用的设置中卸载了所有 Google Play 服务的更新,所有 +1 按钮都正常显示了。 让我们希望 Google 能够修复他们的更新。


0
新的Google Play更新更改了plusOne按钮的界面,因此破坏了所有基于“旧”Google play服务SDK的plusOne按钮。如果您检查他们的示例,您会发现他们已经改变了plusOnButton.initialize的界面,它不再需要“plusOneClient”,而是需要URL。
为了解决这个问题,请使用您的“Android SDK Manager”下载最新的(v13)Google Play Services,并将其导入到您的项目中。

更新是什么时候的?我在三天前尝试过。我知道他们把客户端改成了构建器。 - Asthme

0
试试这个:
在 XML 文件中:
    <com.google.android.gms.common.SignInButton
        android:id="@+id/sign_in_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="92dp" >
    </com.google.android.gms.common.SignInButton>

</RelativeLayout>

在你的活动中获取那个按钮:
    @Override
    public void onCreate(Bundle pBundle) {
    super.onCreate(pBundle);
    setContentView(R.layout.dashboard);

    findViewById(R.id.sign_in_button).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick
                    (View v) {
                        Intent i = new Intent(getApplicationContext(),YourActivity.class);
                        startActivity(i);
                    }
                });
}

你的Youractivity.class是什么?我需要在我的应用程序中进行签名吗? - Asthme
你的G+按钮变成红色了吗?请告诉我。 - Shailendra Madda
有些应用程序没有登录按钮,它们会获取默认的Gmail地址并自动登录。这是可能的吗? - Asthme
嘿,如果一个人有多个账户,它会在对话框中弹出。每次打开应用程序时都会弹出,这是错误的方法。当登录到Google Play时,它会要求权限(例如发布在您的时间轴上等)。对于G+1不需要权限。 - Asthme
@DivyaRamakrishnan,我认为你对权限的理解是错误的。它们确实需要GET_ACCOUNTS权限...至少以前是这样的。 - Amel Jose
显示剩余5条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接