本文整理汇总了Java中com.google.android.gms.tasks.Task.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java Task.getResult方法的具体用法?Java Task.getResult怎么用?Java Task.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.tasks.Task
的用法示例。
在下文中一共展示了Task.getResult方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSignInResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
ChatWindowConfiguration config = new ChatWindowConfiguration(
Config.license,
Config.group,
account.getDisplayName(),
account.getEmail(),
new HashMap<String, String>()
);
// Signed in successfully, show authenticated UI.
launchChat(this, config);
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.w("Whoopsie", "signInResult:failed code=" + e.getStatusCode());
}
}
示例2: onComplete
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onComplete(@NonNull Task<T> task) {
if (isDisposed()) return;
if (task.isSuccessful()) {
T result = task.getResult();
if (result == null) {
observer.onComplete();
} else {
observer.onSuccess(result);
}
} else {
try {
observer.onError(task.getException());
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.onError(new CompositeException(task.getException(), t));
}
}
}
示例3: listener
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
/**
* @param emit
* @param <R>
* @return
*/
@NonNull
@CheckReturnValue
public static <R> OnCompleteListener<R> listener(@NonNull final MaybeEmitter<R> emit) {
return new OnCompleteListener<R>() {
@Override
public void onComplete(@NonNull final Task<R> task) {
if (!emit.isDisposed()) {
if (task.isSuccessful()) {
R result = task.getResult();
if (result != null) {
emit.onSuccess(result);
}
emit.onComplete();
} else {
Exception e = task.getException();
emit.onError(e != null ? e : new RuntimeException());
}
}
}
};
}
示例4: onActivityResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = task.getResult(ApiException.class);
firebaseAuthWithGoogle(account);
} catch (ApiException e) {
// Google Sign In failed, update UI appropriately
Log.w(TAG, "Google sign in failed", e);
// ...
}
}
}
示例5: handleSignInResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
private void handleSignInResult(Task<GoogleSignInAccount> completedTask){
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
// Signed in successfully, show authenticated UI.
updateUI(account);
googleSignInAccount = account;
mAuthorizedAccount = account.getAccount();
GetListOfBlogTask task = new GetListOfBlogTask(mAuthorizedAccount);
task.execute();
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Tools.loge("signInResult:failed code=" + e.getStatusCode());
updateUI(null);
}
}
示例6: analyseGoogleLoginResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
public static void analyseGoogleLoginResult(Intent data, AppCompatActivity activity) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
GoogleAuthenticationUtils.authenticateInFirebaseUsingGoogleAccount(account, activity);
} catch (ApiException e) {
Toast.makeText(activity, R.string.authentication_failed, Toast.LENGTH_SHORT).show();
}
}
示例7: handleSignInResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
/**
* Authenticates the user if Google sign in is successful
* @param completedTask completed google sign in task
*/
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
firebaseAuthWithGoogle(account);
// Signed in successfully, show authenticated UI.
//updateUI(account);
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
onFailed();
}
}
示例8: fromActivityResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
public void fromActivityResult(int requestCode, Intent data){
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
onLoginListener.onSuccess(account);
} catch (ApiException e) {
onLoginListener.onFailed(e+"");
}
}
}
示例9: subscribe
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override public void subscribe(final MaybeEmitter<List<String>> emitter) {
final OnCompleteListener<ProviderQueryResult> listener =
new OnCompleteListener<ProviderQueryResult>() {
@Override public void onComplete(@NonNull Task<ProviderQueryResult> task) {
if (!task.isSuccessful()) {
if (!emitter.isDisposed()) {
emitter.onError(task.getException());
}
return;
}
if (!emitter.isDisposed()) {
ProviderQueryResult result = task.getResult();
if (result != null) {
List<String> providers = result.getProviders();
if (providers != null) {
emitter.onSuccess(providers);
return;
}
}
emitter.onComplete();
}
}
};
instance.fetchProvidersForEmail(email).addOnCompleteListener(listener);
}
示例10: onActivityResult
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case RC_SIGN_IN:
Task<GoogleSignInAccount> task =
GoogleSignIn.getSignedInAccountFromIntent(intent);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
onConnected(account);
} catch (ApiException apiException) {
String message = apiException.getMessage();
message = getString(R.string.signin_other_error) + " " + "(" + message + ")";
onDisconnected();
new AlertDialog.Builder(this)
.setTitle(R.string.error_during_signin)
.setMessage(message + apiException.toString())
.setNeutralButton(android.R.string.ok, null)
.show();
}
break;
case RC_SELECT_PLAYERS:
// we got the result from the "select players" UI -- ready to create the room
handleSelectPlayersResult(resultCode, intent);
break;
case RC_INVITATION_INBOX:
// we got the result from the "select invitation" UI (invitation inbox). We're
// ready to accept the selected invitation:
handleInvitationInboxResult(resultCode, intent);
break;
case RC_WAITING_ROOM:
// we got the result from the "waiting room" UI.
if (resultCode == Activity.RESULT_OK) {
// ready to start playing
Log.d("ROOM", "Starting game (waiting room returned OK).");
startGame();
} else if (resultCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
// player indicated that they want to leave the room
} else if (resultCode == Activity.RESULT_CANCELED) {
// Dialog was cancelled (user pressed back key, for instance). In our game,
// this means leaving the room too. In more elaborate games, this could mean
// something else (like minimizing the waiting room UI).
}
break;
}
super.onActivityResult(requestCode, resultCode, intent);
}