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


Java Task.getResult方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:coe-google-apps-support,项目名称:jazz-android,代码行数:21,代码来源:MainActivity.java

示例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));
        }
    }
}
 
开发者ID:niqo01,项目名称:RxTask,代码行数:20,代码来源:MaybeTaskCallback.java

示例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());
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:rxtasks,代码行数:27,代码来源:RxTask.java

示例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);
            // ...
        }
    }
}
 
开发者ID:mangoblogger,项目名称:MangoBloggerAndroidApp,代码行数:19,代码来源:BaseAuthActivity.java

示例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);
    }
}
 
开发者ID:thenewpotato,项目名称:Blogg,代码行数:20,代码来源:MainActivity.java

示例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();
    }
}
 
开发者ID:lmnpWmi,项目名称:wirtualnaApteczka,代码行数:11,代码来源:GoogleAuthenticationUtils.java

示例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();
    }
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:18,代码来源:GoogleAuthenticator.java

示例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+"");
        }
    }
}
 
开发者ID:shivam301296,项目名称:HiGoogle,代码行数:12,代码来源:HiGoogle.java

示例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);
  }
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:29,代码来源:FetchProvidersForEmailOnSubscribe.java

示例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);

}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:56,代码来源:AbsRoomActivity.java


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