<i id='rzAMg'><tr id='rzAMg'><dt id='rzAMg'><q id='rzAMg'><span id='rzAMg'><b id='rzAMg'><form id='rzAMg'><ins id='rzAMg'></ins><ul id='rzAMg'></ul><sub id='rzAMg'></sub></form><legend id='rzAMg'></legend><bdo id='rzAMg'><pre id='rzAMg'><center id='rzAMg'></center></pre></bdo></b><th id='rzAMg'></th></span></q></dt></tr></i><div id='rzAMg'><tfoot id='rzAMg'></tfoot><dl id='rzAMg'><fieldset id='rzAMg'></fieldset></dl></div>
<legend id='rzAMg'><style id='rzAMg'><dir id='rzAMg'><q id='rzAMg'></q></dir></style></legend>

    <small id='rzAMg'></small><noframes id='rzAMg'>

  1. <tfoot id='rzAMg'></tfoot>
    • <bdo id='rzAMg'></bdo><ul id='rzAMg'></ul>

      onConnectionFailed 给 SIGN_IN_REQUIRED(4)

      onConnectionFailed giving SIGN_IN_REQUIRED(4)(onConnectionFailed 给 SIGN_IN_REQUIRED(4))

      <legend id='ikJYm'><style id='ikJYm'><dir id='ikJYm'><q id='ikJYm'></q></dir></style></legend>
    1. <small id='ikJYm'></small><noframes id='ikJYm'>

        <bdo id='ikJYm'></bdo><ul id='ikJYm'></ul>

          <i id='ikJYm'><tr id='ikJYm'><dt id='ikJYm'><q id='ikJYm'><span id='ikJYm'><b id='ikJYm'><form id='ikJYm'><ins id='ikJYm'></ins><ul id='ikJYm'></ul><sub id='ikJYm'></sub></form><legend id='ikJYm'></legend><bdo id='ikJYm'><pre id='ikJYm'><center id='ikJYm'></center></pre></bdo></b><th id='ikJYm'></th></span></q></dt></tr></i><div id='ikJYm'><tfoot id='ikJYm'></tfoot><dl id='ikJYm'><fieldset id='ikJYm'></fieldset></dl></div>

        1. <tfoot id='ikJYm'></tfoot>
              <tbody id='ikJYm'></tbody>

              1. 本文介绍了onConnectionFailed 给 SIGN_IN_REQUIRED(4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在开发一个想要使用 Google API 的 Android 应用程序.为此,我导入了 google-play-service-lib 项目.

                我正在关注这个 链接 来初始化 GoogleApiClient 对象.p>

                我的代码:

                1) 在 onCreate() 方法中,我正在构建 GoogleApiClient 对象:

                mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(这个).addOnConnectionFailedListener(这个).addApi(Plus.API, null).addScope(Plus.SCOPE_PLUS_LOGIN).建造();

                2) 在onStart()中,我调用mGoogleApiClient.connect().

                3) 我的活动实现ConnectionCallbacksOnConnectionFailedListener.

                4) 我的 onConnectionFailed() 方法如下所示:

                public void onConnectionFailed(ConnectionResult 结果) {//在 dubug 结果中看起来像:ConnectionResult{//statusCode=SIGN_IN_REQUIRED,分辨率=PendingIntent//{41f8ca70: android.os.BinderProxy@41f8ca10}}尝试 {if(!mIntentInProgress && result.hasResolution()){mIntentInProgress=true;result.startResolutionForResult(mActivity, RC_SIGN_IN);}} 捕捉(SendIntentException e){e.printStackTrace();}}

                5) 我的 onActivityResult() 方法包含:

                if (requestCode == RC_SIGN_IN) {if (!mGoogleApiClient.isConnecting()) {mGoogleApiClient.connect();}}

                当我运行我的应用程序时,我得到一个 Toast 表示弹出了一个内部错误.我确实在 Google 控制台中创建了该项目.

                解决方案

                我也遇到了同样的问题.

                来自文档:客户端可以选择不使用 API 继续,也可以调用 startResolutionForResult(Activity, int) 提示用户登录.

                所以你应该尝试使用 startResolutionForResult() 函数登录

                @Override公共无效onConnectionFailed(连接结果结果){if (result.hasResolution()) {尝试 {//!!!result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);} 捕捉(SendIntentException e){mPlusClient.connect();}}mConnectionResult = 结果;}

                I am developing an Android application where I want to use the Google API. For that I have imported the google-play-service-lib project.

                I am following this link to initialize GoogleApiClient object.

                My code:

                1) In the onCreate() method I am building the GoogleApiClient object:

                mGoogleApiClient = new GoogleApiClient.Builder(this)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(Plus.API, null)
                    .addScope(Plus.SCOPE_PLUS_LOGIN)
                    .build();
                

                2) In onStart(), I call mGoogleApiClient.connect().

                3) My activity implements ConnectionCallbacks and OnConnectionFailedListener.

                4) My onConnectionFailed() method looks like:

                public void onConnectionFailed(ConnectionResult result) {
                    //in dubug result looks like : ConnectionResult{
                    //statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent
                                    // {41f8ca70: android.os.BinderProxy@41f8ca10}}
                     try {
                     if(!mIntentInProgress && result.hasResolution())
                     {
                         mIntentInProgress=true;
                        result.startResolutionForResult(mActivity, RC_SIGN_IN);
                          }
                
                    } catch (SendIntentException e) {
                        e.printStackTrace();
                    }
                }
                

                5) My onActivityResult() method contains:

                if (requestCode == RC_SIGN_IN) {
                   if (!mGoogleApiClient.isConnecting()) {
                      mGoogleApiClient.connect();
                   }
                }
                

                When I run my app I get a Toast that says that an internal error popped up. I did create the project in the Google console.

                解决方案

                I had the same problem.

                From documentation: The client may choose to continue without using the API or it may call startResolutionForResult(Activity, int) to prompt the user to sign in.

                So you should try to sign in by using startResolutionForResult() function

                @Override
                public void onConnectionFailed(ConnectionResult result) {
                   if (result.hasResolution()) {
                       try {
                           // !!!
                           result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                       } catch (SendIntentException e) {
                           mPlusClient.connect();
                       }
                   }
                
                   mConnectionResult = result;
                }
                

                这篇关于onConnectionFailed 给 SIGN_IN_REQUIRED(4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Android - Is it possible to get install referrer programmatically(Android - 是否有可能以编程方式安装引荐来源网址)
                How to sign an APK with more than one certificate?(如何使用多个证书签署 APK?)
                versionCode vs versionName in Android Manifest(Android Manifest 中的 versionCode 与 versionName)
                What does this Google Play APK publish error message mean?(这个 Google Play APK 发布错误消息是什么意思?)
                Lost my keystore for uploaded app on android market(丢失了我在 android 市场上上传的应用程序的密钥库)
                App on Google Play always shows quot;Updatequot; instead of open(Google Play 上的应用程序总是显示“更新;而不是打开)
                <legend id='tBZuJ'><style id='tBZuJ'><dir id='tBZuJ'><q id='tBZuJ'></q></dir></style></legend>
                  <bdo id='tBZuJ'></bdo><ul id='tBZuJ'></ul>
                • <i id='tBZuJ'><tr id='tBZuJ'><dt id='tBZuJ'><q id='tBZuJ'><span id='tBZuJ'><b id='tBZuJ'><form id='tBZuJ'><ins id='tBZuJ'></ins><ul id='tBZuJ'></ul><sub id='tBZuJ'></sub></form><legend id='tBZuJ'></legend><bdo id='tBZuJ'><pre id='tBZuJ'><center id='tBZuJ'></center></pre></bdo></b><th id='tBZuJ'></th></span></q></dt></tr></i><div id='tBZuJ'><tfoot id='tBZuJ'></tfoot><dl id='tBZuJ'><fieldset id='tBZuJ'></fieldset></dl></div>

                      <tbody id='tBZuJ'></tbody>

                      • <tfoot id='tBZuJ'></tfoot>

                        <small id='tBZuJ'></small><noframes id='tBZuJ'>