0

google pluse 自動ログインを使用しようとしています。

SignInButton ボタン ウィジェットを使用します。

ログインをクリックすると進行状況ダイアログが表示されますが、onConnected がトリガーされません

これは私の尻のプレスコードです:

case R.id.sign_in_button:
        {
            if(!mPlusClient.isConnected())
            {
                if (mConnectionResult == null) {
                    {
                        pDialog = new ProgressDialog(RegisterPage.this);
                        pDialog.setMessage("logging in...");
                        pDialog.setIndeterminate(false);
                        pDialog.setCancelable(true);
                        pDialog.show();
                    }
                } else {
                    try {
                        mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                    } catch (SendIntentException e) {
                        // Try connecting again.
                        mConnectionResult = null;
                        mPlusClient.connect();
                    }
                }

            break;
        }

私の onConnected コード:

@Override
    public void onConnected(Bundle arg0) {
        // TODO Auto-generated method stub
         Log.i("ok", "ok");

        if (mPlusClient.getCurrentPerson() != null && isNetworkAvailable())
            new GooglePlusRegister().execute();
        else
        {
            if(pDialog != null)
                pDialog.dismiss();

            Toast.makeText(getApplicationContext(),"No internet connection", Toast.LENGTH_SHORT).show();
        }
    }

進行状況ダイアログが表示されず、ログ呼び出しが表示されません。

私のonCreateで:

mPlusClient = new PlusClient.Builder(this, this , this).setScopes(Scopes.PLUS_LOGIN).setVisibleActivities("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity").build();

輸入品:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.plus.PlusClient;
import com.google.android.gms.plus.model.people.Person;
4

1 に答える 1

2

コードをもう一度見てください:mPlusClient.connect()は決して実行されません。

条件ステートメントif (mConnectionResult == null)は、実際に Google Plus に接続せずに ProgressDialog のみを表示しています。

エラー状態を処理する正しい方法を確認する必要がありますが、私の頭の上から、elseステートメントの行を削除するだけで問題が解決する場合があります。

于 2013-10-02T22:39:29.233 に答える