Android上的Google登录错误

时间:2015-07-03 18:20:45

标签: android google-login

我的应用说:

  

Google Play服务不可用。此应用程序将关闭

我使用的代码是https://github.com/googleplus/gplus-quickstart-android

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

目前尚不清楚您是否正在检查设备上是否安装了GooglePlayServices。我没有看到您链接到的代码中的检查。

This webpage 介绍了如何验证设备上是否安装了GooglePlayServices以及如何处理故障。该信息不是完全最新的,但仍然提供了良好的处理轮廓。 GooglePlayServicesUtil类提供了检查PlayServices是否已安装的方法,并显示了允许用户安装PlayForvices的对话框(如果缺少)。

网页上的一些代码:

private boolean checkPlayServices() {
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (status != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
            showErrorDialog(status);
        } else {
            Toast.makeText(this, "This device is not supported.",
                    Toast.LENGTH_LONG).show();
            finish();
        }
        return false;
    }
    return true;
}

private int REQUEST_CODE = 1234;

private void showErrorDialog(int code) {
    GooglePlayServicesUtil.getErrorDialog(code, this, REQUEST_CODE).show();
}

答案 1 :(得分:0)

我在这里播放一些代码并给你建议:

  strings.xml:

 <string name="lbl_play_service">This application needs Google Play Service, you must install it first.</string>
    <string name="play_service_url">market://details?id=com.google.android.gms</string>
<string name="play_service_web">https://play.google.com/store/apps/details?id=com.google.android.gms</string>

Some javas:

    @Override
protected void onResume() {
    super.onResume();
    checkPlayService();
}

/**
 * To confirm whether the validation of the Play-service of Google Inc.
 */
private void checkPlayService() {
    final int isFound = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (isFound == ConnectionResult.SUCCESS) {
       //Device has updated version of play-service.
    } else {
       //You need to store to update play-service.
        new Builder(this).setTitle(R.string.application_name).setMessage(R.string.lbl_play_service).setCancelable(
                false).setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(getString(R.string.play_service_url)));
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e0) {
                    intent.setData(Uri.parse(getString(R.string.play_service_web)));
                    try {
                        startActivity(intent);
                    } catch (Exception e1) {
                        //Ignore now.
                    }
                } finally {
                    finish();
                }
            }
        }).create().show();
    }
}