当前位置: 首页>>代码示例>>Java>>正文


Java OptionalPendingResult类代码示例

本文整理汇总了Java中com.google.android.gms.common.api.OptionalPendingResult的典型用法代码示例。如果您正苦于以下问题:Java OptionalPendingResult类的具体用法?Java OptionalPendingResult怎么用?Java OptionalPendingResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OptionalPendingResult类属于com.google.android.gms.common.api包,在下文中一共展示了OptionalPendingResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onStart(){
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);

    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:25,代码来源:SignInActivity.java

示例2: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
protected void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if(pendingResult.isDone()){
        Log.d(TAG,"onStart(): Cached sign in");
        GoogleSignInResult result = pendingResult.get();
        handleSignInResult(result);
    } else {
        showProgressDialog();
        pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:CSI-KJSCE,项目名称:CSI-KJSCEOfficial,代码行数:20,代码来源:LoginActivity.java

示例3: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onStart() {
    super.onStart();
    mAuth.addAuthStateListener(mAuthListener);

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.

        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {

                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:othreecodes,项目名称:WaJeun,代码行数:27,代码来源:MainActivity.java

示例4: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:igrow-systems,项目名称:igrow-android,代码行数:26,代码来源:SignInActivity.java

示例5: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:Wisebite,项目名称:wisebite_android,代码行数:25,代码来源:LoginActivity.java

示例6: handleSilentSignIn

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
private void handleSilentSignIn(){

        OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);

        if (pendingResult.isDone()) {
            // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
            // and the GoogleSignInResult will be available instantly.
            Log.d(Utils.TAG, "Got cached sign-in");
            GoogleSignInResult result = pendingResult.get();
            handleSignInResult(result);
        } else {
            pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                @Override
                public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                    handleSignInResult(googleSignInResult);
                }
            });
        }
    }
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:20,代码来源:UpdateFragment.java

示例7: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        GoogleSignInResult result = opr.get();
        handleGoogleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        mAuthProgressDialog.show();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                handleGoogleSignInResult(googleSignInResult);
            }
        });
    }

    mFirebaseRef.addAuthStateListener(mAuthStateListener);
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:26,代码来源:LoginActivity.java

示例8: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
public void onStart() {
	OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
	if (opr.isDone()) {
		// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
		// and the GoogleSignInResult will be available instantly.
		AppLogger.debug("Got cached sign-in");
		GoogleSignInResult result = opr.get();
		handleSignInResult(result);
	} else {
		// If the user has not previously signed in on this device or the sign-in has expired,
		// this asynchronous branch will attempt to sign in the user silently.  Cross-device
		// single sign-on will occur in this branch.
		showProgressDialog();
		opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
			@Override
			public void onResult(GoogleSignInResult googleSignInResult) {
				hideProgressDialog();
				handleSignInResult(googleSignInResult);
			}
		});
	}
}
 
开发者ID:NovaViper,项目名称:TrinityLocker,代码行数:23,代码来源:AuthManager.java

示例9: onResume

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onResume() {
    super.onResume();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:asifali22,项目名称:Focus-Android-App,代码行数:25,代码来源:LoginActivity.java

示例10: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
protected void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:asifali22,项目名称:Focus-Android-App,代码行数:25,代码来源:LoginActivity.java

示例11: SingInIntent

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
public void SingInIntent() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:asifali22,项目名称:Focus-Android-App,代码行数:23,代码来源:LoginActivity.java

示例12: confirmCredential

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public Bundle confirmCredential(AccountAuthenticatorResponse response, Account account, Bundle data) {
    final Bundle bundle = new Bundle();
    if (TextUtils.isEmpty(data.getString(AccountManager.KEY_AUTHTOKEN))) {
        final OptionalPendingResult<GoogleSignInResult> pendingResult = GoogleApiAdapter.getInstance().performSilentSignIn();
        if (pendingResult != null) {
            final GoogleSignInResult googleSignInResult = pendingResult.get();
            if (googleSignInResult != null) {
                final GoogleSignInAccount signInAccount = googleSignInResult.getSignInAccount();
                if (signInAccount != null) {
                    bundle.putString(AccountManager.KEY_AUTHTOKEN, signInAccount.getIdToken());
                    bundle.putString(AccountManager.KEY_ACCOUNT_NAME, signInAccount.getDisplayName());
                }
            }
        }
    } else {
        bundle.putString(AccountManager.KEY_AUTHTOKEN, data.getString(AccountManager.KEY_AUTHTOKEN));
    }
    bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
    bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, AuthenticAuthenticator.ACCOUNT_TYPE);
    bundle.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, !TextUtils.isEmpty(bundle.getString(AccountManager.KEY_AUTHTOKEN)));
    return bundle;
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:24,代码来源:GoogleStrategy.java

示例13: onConnected

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onConnected(Bundle connectionHint) {
  Timber.d("onConnected");
  if (shouldAutoLogin) {
    OptionalPendingResult<GoogleSignInResult> pendingResult =
            googleApiClientBridge.silentSignIn(googleApiClientToken);
    if (pendingResult.isDone()) {
      // There's immediate result available.
      handleSignInResult(pendingResult.get());
    } else {
      // There's no immediate result ready
      pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
        @Override
        public void onResult(@NonNull GoogleSignInResult result) {
          handleSignInResult(result);
        }
      });
    }
  }
}
 
开发者ID:chiuki,项目名称:friendspell,代码行数:21,代码来源:MainActivity.java

示例14: onStart

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@Override
public void onStart() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Config.debug(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);

    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        Config.debug(TAG, "New sign-in");
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
 
开发者ID:nishant-git,项目名称:social-api,代码行数:26,代码来源:GoogleService.java

示例15: signInLegacyUser

import com.google.android.gms.common.api.OptionalPendingResult; //导入依赖的package包/类
@WorkerThread
public Observable<GoogleSignInUser> signInLegacyUser() {
    if (mGoogleApiClient == null) {
        TbaLogger.i("Lazy loading Google API Client for legacy sign in");
        loadGoogleApiClient();
    }
    if (mGoogleApiClient == null) {
        TbaLogger.i("Unable to get API Client for legacy sign in");
        return Observable.empty();
    }
    onStart();
    OptionalPendingResult<GoogleSignInResult> optionalResult = Auth.GoogleSignInApi
            .silentSignIn(mGoogleApiClient);
    GoogleSignInResult result = optionalResult.await();
    onStop();
    if (result.isSuccess()) {
        return Observable.just(new GoogleSignInUser(result.getSignInAccount()));
    } else {
        TbaLogger.w("Unable to complete legacy sign in: " + result.getStatus().getStatusMessage());
    }
    return Observable.empty();
}
 
开发者ID:the-blue-alliance,项目名称:the-blue-alliance-android,代码行数:23,代码来源:GoogleAuthProvider.java


注:本文中的com.google.android.gms.common.api.OptionalPendingResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。