智能客服
你问我答,随时在线为你解决问题
日落公告:HMS Toolkit服务当前已不再进行版本更新。中国区域的服务将在2026-11-30日落下线,日落后将不再提供服务。
根据Callable的执行结果返回一个新的任务。Callable在主线程中运行。
Google API | To HMS API |
|---|---|
public static <TResult> com.google.android.gms.tasks.Task<TResult> call(java.util.concurrent.Executor,java.util.concurrent.Callable) | public static <TResult> com.huawei.hmf.tasks.Task<TResult> callInBackground(java.util.concurrent.Executor executor, final java.util.concurrent.Callable<TResult> callable) 对应HMS类:com.huawei.hmf.tasks.Tasks |
public static <TResult> com.google.android.gms.tasks.Task<TResult> call(java.util.concurrent.Callable) | public static <TResult> com.huawei.hmf.tasks.Task<TResult> callInBackground(java.util.concurrent.Executor executor, final java.util.concurrent.Callable<TResult> callable) 对应HMS类:com.huawei.hmf.tasks.Tasks |
client连接到华为移动服务。 这个方法立即返回,连接服务在后台进行。
Google API | To HMS API |
|---|---|
abstract void connect() | abstract void connect(android.app.Activity activity) activity内部已做判空处理。 对应HMS类:com.huawei.hms.api.HuaweiApiClient 说明:如果该接口是用于fitness业务,请将GoogleApiClient替换为HiHealthKitClient,使用HiHealthKitClient.connect()接口来连接华为运动健康服务。可以参见add接口中To HMS API内容修改。 |
使能生命周期自动管理。
Google API | To HMS API |
|---|---|
public final com.google.android.gms.common.api.GoogleApiClient.Builder enableAutoManage(androidx.fragment.app.FragmentActivity, com.google. android.gms.common.api.GoogleApiClient.OnConnectionFailedListener) | public com.huawei.hms.api.HuaweiApiClient.Builder allowLifeCycleManagement(android.app.Activity activity, com.huawei.hms.api.HuaweiApiClient.OnConnectionFailedListener unresolvedConnectionFailedListener) unresolvedConnectionFailedListener:OnConnectionFailedListener回调。 对应HMS类:com.huawei.hms.api.HuaweiApiClient |
public final com.google.android.gms.common.api.GoogleApiClient.Builder enableAutoManage(androidx.fragment.app.FragmentActivity, int, com.google. android.gms.common.api.GoogleApiClient.OnConnectionFailedListener) | public com.huawei.hms.api.HuaweiApiClient.Builder allowLifeCycleManagement(android.app.Activity activity, int clientId, com.huawei.hms.api.HuaweiApiClient.OnConnectionFailedListener unresolvedConnectionFailedListener) clientId:可自动转化,原入参复用。 unresolvedConnectionFailedListener:OnConnectionFailedListener回调 对应HMS类:com.huawei.hms.api.HuaweiApiClient |
获得PendingIntent对象,其中包含解决方案。
Google API | To HMS API |
|---|---|
public final android.app.PendingIntent getErrorPendingIntent(int, android.content.Context, int) | public abstract android.app.PendingIntent getErrPendingIntent(android.app.Activity activity, int errorCode, int requestCode) errorCode:错误码 requestCode:请求码 对应HMS类:com.huawei.hms.api.HuaweiApiAvailability |
获得PendingIntent对象,其中包含解决方案。
Google API | To HMS API |
|---|---|
android.app.PendingIntent getErrorResolutionPendingIntent (android.content.Context, com.google.android.gms.common.ConnectionResult) | android.app.PendingIntent getErrPendingIntent(android.app.Activity activity, com.huawei.hms.api.ConnectionResult result) result:此类描述了所有client向HMS连接失败时的结果码。 对应HMS类:com.huawei.hms.api.HuaweiApiAvailability |
android.app.PendingIntent getErrorResolutionPendingIntent (android.content.Context, int, int) | android.app.PendingIntent getErrPendingIntent(android.app.Activity activity, int errorCode, int requestCode) errorCode:错误码 requestCode:请求码 对应HMS类:com.huawei.hms.api.HuaweiApiAvailability |
SDK 的版本号。
Google API | To HMS API |
|---|---|
public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE = 12451000 | public static int SERVICES_VERSION_CODE = 30000100 对应HMS类:com.huawei.hms.api.HuaweiApiAvailability |
自动升级、安装平台安全控件。
Google API | To HMS API |
|---|---|
public static void installIfNeeded(android.content.Context) | public static void install(android.content.Context context) 对应HMS类:com.huawei.hms.security.SecComponentInstallWizard |
获取UI主线程的执行类实例。
Google API | To HMS API |
|---|---|
java.util.concurrent.Executor MAIN_THREAD | public static Executor uiThread() 对应HMS类:com.huawei.hmf.tasks.TaskExecutors |
任务取消回调。
Google API | To HMS API |
|---|---|
public abstract com.google.android.gms.tasks.CancellationToken com.google.android.gms.tasks.CancellationToken.onCanceledRequested (com.google.android.gms.tasks.OnTokenCanceledListener listener) | public abstract com.huawei.hmf.tasks.CancellationToken com.huawei.hmf.tasks.CancellationToken.register(java.lang.Runnable action) |
connect(Activity)方法调用后,当连接成功时此方法会被异步地调用。此方法回调后,应用程序就可以进行client提供的其他请求了。
Google API | To HMS API |
|---|---|
void onConnected(android.os.Bundle param) | void onConnected() 对应HMS类:com.huawei.hms.api.HuaweiApiClient.ConnectionCallbacks |
安装成功监听器。
Google API | To HMS API |
|---|---|
void onProviderInstalled() | abstract void onSuccess() 对应HMS类:com.huawei.hms.security.SecComponentInstallWizard.SecComponentInstallWizardListener |
安装失败监听器。
Google API | To HMS API |
|---|---|
void onProviderInstallFailed(int, android.content.Intent) | abstract void onFailed(int errorCode, android.content.Intent recoveryIntent) errorCode:错误码 recoveryIntent:解决方案 对应HMS类:com.huawei.hms.security.SecComponentInstallWizard.SecComponentInstallWizardListener |
显示Dialog。
Google API | To HMS API |
|---|---|
public void show(androidx.fragment.app.FragmentManager, java.lang.String) | public void show(android.app.FragmentManager manager, java.lang.String tag) 对应HMS类:com.huawei.hms.common.ErrDlgFragmentForSupport |
展示ErrorDialog,参数isHuaweiMobileServicesAvailable返回的错误码。
Google API | To HMS API |
|---|---|
public final boolean showErrorDialogFragment (int, android.app.Activity,androidx.fragment.app. Fragment, int, android.content.DialogInterface.OnCancelListener) | public static boolean popupErrDlgFragment(int errorCode, android.app.Activity activity, android.app.Fragment fragment, int requestCode, android.content.DialogInterface.OnCancelListener cancelListener) requestCode:请求码 对应HMS类:com.huawei.hms.api.HuaweiMobileServicesUtil |
断开客户端连接并停止自动生命周期管理,在创建新客户端之前使用此功能,必须从主线程调用此方法。
Google API | To HMS API |
|---|---|
abstract void stopAutoManage(androidx.fragment.app.FragmentActivity lifecycleActivity) | public abstract void disableLifeCycleManagement(android.app.Activity activity) activity可自动转化,原入参复用。 对应HMS类:com.huawei.hms.api.HuaweiApiClient |
设置异常。
Google API | To HMS API |
|---|---|
public boolean com.google.android.gms.tasks.TaskCompletionSource<TResult>.trySetException (java.lang.Exception exception) | public void com.huawei.hmf.tasks.TaskCompletionSource<TResult>.setException(java.lang.Exception exception) |
设置接口调用结果。
Google API | To HMS API |
|---|---|
public boolean com.google.android.gms.tasks.TaskCompletionSource<TResult>.trySetResult (TResult result) | public void com.huawei.hmf.tasks.TaskCompletionSource<TResult>.setResult(TResult result) |