【问题标题】:my Google+1 button is grayed out and not working?我的 Google+1 按钮显示为灰色且无法使用?
【发布时间】:2013-11-18 15:44:17
【问题描述】:

我正在尝试将 G+ 按钮集成到 ma 应用程序中。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+,它昨天和今天本身也是灰色的。我想可能是googleplayservice遇到了问题。
  • @NitinMisra 哦好的让我知道它何时工作,如果我先知道我会告诉你

标签: android google-plus google-play-services google-plus-one


【解决方案1】:

试试这个:

在 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 是什么?我应该登录我的应用吗?
  • 那是你要开始的活动。这里你需要提到你的SignInActivity。你需要编写登录到你的应用程序的逻辑。
  • 你的 G+ 按钮变成红色了吗,让我知道吗?
  • 某些应用没有登录按钮,他们正在获取默认的gmail地址并自动登录。可能吗?
  • 欢迎 :),您是否想在打开应用程序时直接进入我们执行的按钮单击操作的登录页面?
【解决方案2】:

问题在于 Google Play 服务的最新更新。 一旦我从应用程序的设置中卸载了谷歌播放服务的所有更新,所有 +1 按钮都显示正常。 希望谷歌能修复他们的更新。

【讨论】:

    【解决方案3】:

    新的 Google Play 更新更改了 plusOne 按钮的界面,因此打破了所有基于“旧”Google Play 服务 SDK 的 plusOne 按钮。 如果您查看他们的示例,您会发现他们更改了 plusOnButton.initialize 的接口,该接口不再需要“plusOneClient”,而是一个 URL。

    要修复,请使用您的“Android SDK 管理器”下载最新的 (v13) Google Play 服务,然后将其导入回您的项目。

    【讨论】:

    • 什么时候更新的。我在三天前尝试过。我知道他们将客户端更改为构建器..
    猜你喜欢
    • 2020-07-16
    • 1970-01-01
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多