目录

Classes

Class nameClass description
HuaweiApiAvailabilityVerifies whether the HMS Core (APK) installed on the device is available and needs to be upgraded.

Constant Summary




TypeNameDesc
StringSERVICES_PACKAGEPackage name of HMS Core (APK).
StringSERVICES_ACTIONAction of the service exported by HMS Core(APK).
StringACTIVITY_NAMECategory of the activity exported from HMS Core (APK).
intNOTICE_VERSION_CODEVersion number of HMS Core (APK) required by the client to obtain notifications.
intHMS_VERSION_MINEarliest HMS Core (APK) version required by each service.
intHMS_JSON_VERSION_MINEarliest HMS Core (APK) version required by each service of the JSON version.
intHMS_VERSION_MAXLatest version that can be configured for a CP.
intHMS_VERSION_CODE_MINEarliest  version that can be configured for a CP.
StringHMS_API_NAME_IDAPI name of the HUAWEI ID service.
intHMS_VERSION_CODE_IDVersion number of the HUAWEI ID service.
StringHMS_API_NAME_SNSAPI name of the SNS service.
intHMS_VERSION_CODE_SNSVersion number of the SNS service.
StringHMS_API_NAME_PAYAPI name of the HUAWEI Pay service.
intHMS_VERSION_CODE_PAYVersion number of the HUAWEI Pay service.
StringHMS_API_NAME_PUSHAPI name of the HUAWEI Push service.
intHMS_VERSION_CODE_PUSHVersion number of the HUAWEI Push service.
StringHMS_API_NAME_GAMEAPI name of the HUAWEI Game service.
intHMS_VERSION_CODE_GAMEVersion number of the HUAWEI Game service.
StringHMS_API_NAME_ODAPI name of the service.
intHMS_VERSION_CODE_ODVersion number of the service.
StringHMS_API_NAME_IAPAPI name of the HUAWEI IAP service.
intHMS_VERSION_CODE_IAPVersion number of the HUAWEI IAP service.
StringHMS_API_NAME_PPSAPI name of the HUAWEI PPS service.
intHMS_VERSION_CODE_PPSVersion number of the HUAWEI PPS service.
intHMS_SDK_VERSION_CODEVersion number of the HMS SDK.
StringHMS_SDK_VERSION_NAMEVersion name of the HMS SDK.

Public Method Summary

Return typeMethod name
Map< String, Integer >getApiMap()
Obtains the API version number of each service.
HuaweiApiAvailabilitygetInstance()
Returns the singleton instance of HuaweiApiAvailability.
intgetServicesVersionCode()
Returns the service version number.
voidsetServicesVersionCode(int servicesVersionCode)
Sets the service version number.
intisHuaweiMobileServicesAvailable(Context context)
Checks whether the HMS Core (APK)  is successfully installed and integrated on the device, and whether the version of the installed HMS APK is the version required by the client or is later than the required version.
intisHuaweiMobileServicesAvailable(Context context, int minApkVersion)
Checks whether the HMS Core (APK) is successfully installed and integrated on the device, and whether the version of the installed HMS Core (APK) is the version required by the client or is later than the required version.
intisHuaweiMobileNoticeAvailable(Context context)
Checks whether the HMS Core (APK) version supports notification receipt.
booleanisUserResolvableError(int errorCode)
Determines whether a failure can be resolved via user action.
voidresolveError(Activity activity, int errorCode, int requestCode)
If an issue can be resolved through user operations, a notification or dialog box is displayed for the returned error code.
voidresolveError(Activity activity, int errorCode, int requestCode, PendingIntent pendingIntent)
If an issue can be resolved through user operations, a notification or dialog box is displayed for the returned error code.
PendingIntentgetResolveErrorPendingIntent(Activity activity, int errorCode)
Constructs a pending intent that can resolve the issue.
IntentgetResolveErrorIntent(Activity activity, int errorCode)
Constructs a pending intent that can resolve the issue.
DialoggetErrorDialog(Activity activity, int errorCode, int requestCode)
Displays a notification/dialog box for the error code returned by the isHuaweiMobileServicesAvailable(Context, int) method.
DialoggetErrorDialog(Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener onCancelListener)
Displays a notification/dialog box for the error code returned by the isHuaweiMobileServicesAvailable(Context, int) method.
StringgetErrorString(int errorCode )
human-readable string of the error code returned from isHuaweiMobileServicesAvailable(Context, int).
booleanshowErrorDialogFragment (Activity activity, int errorCode, int requestCode)
Creates and displays a dialog box for an error code.
booleanshowErrorDialogFragment (Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener cancelListener)
Creates and displays a dialog box for an error code.
voidshowErrorNotification(Context context, int errorCode)
Creates and displays a dialog for an error code.

Constants

Constant
public static final String SERVICES_PACKAGE
Package name of HMS Core (APK).
Constant Value: “com.huawei.hwid”
Constant
public static final String SERVICES_ACTION
Action of the service exported by HMS Core (APK).
Constant Value: “com.huawei.hms.core.aidlservice”
Constant
public static final String ACTIVITY_NAME
Category of the activity exported from HMS Core (APK).
Constant Value: “com.huawei.hms.core.activity.JumpActivity”
Constant
public static final int NOTICE_VERSION_CODE
Version number of HMS Core (APK) required by the client to obtain notifications.
Constant Value: “20600000”
Constant
public static final int HMS_VERSION_MIN
Earliest HMS Core (APK) version required by each service.
Constant Value: “20503000”
Constant
public static final int HMS_JSON_VERSION_MIN
Earliest HMS Core (APK) version required by each service of the JSON version.
Constant Value: “20701200”
Constant
public static final int HMS_VERSION_MAX
Latest version that can be configured for a CP.
Constant Value: “20600000”
Constant
public static final int HMS_VERSION_CODE_MIN
Earliest version that can be configured for a CP.
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_ID
API name of the HUAWEI ID service.
Constant Value: “HuaweiID.API”
Constant
public static final int HMS_VERSION_CODE_ID
Version number of the HUAWEI ID service.
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_SNS
API name of the SNS service.
Constant Value: “HuaweiSns.API”
Constant
public static final int HMS_VERSION_CODE_SNS
Version number of the SNS service.
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_PAY
API name of the HUAWEI Pay service.
Constant Value: “HuaweiPay.API”
Constant
public static final int HMS_VERSION_CODE_PAY
Version number of the HUAWEI Pay service.
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_PUSH
API name of the HUAWEI Push service.
Constant Value: “HuaweiPush.API”
Constant
public static final int HMS_VERSION_CODE_PUSH
Version number of the HUAWEI Push service.
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_GAME
API name of the HUAWEI Game service.
Constant Value: “HuaweiGame.API”
Constant
public static final int HMS_VERSION_CODE_GAME
Version number of the HUAWEI Game service.
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_OD
API name of the service.
Constant Value: “HuaweiOpenDevice.API”
Constant
public static final int HMS_VERSION_CODE_OD
Version number of the service.
Constant Value: “20601000”
Constant
public static final String HMS_API_NAME_IAP
API name of the HUAWEI IAP service.
Constant Value: “HuaweiIap.API”
Constant
public static final int HMS_VERSION_CODE_IAP
Version number of the HUAWEI IAP service.
Constant Value: “20700300”
Constant
public static final String HMS_API_NAME_PPS
API name of the HUAWEI PPS service.
Constant Value: “HuaweiPPSkit.API”
Constant
public static final int HMS_VERSION_CODE_PPS
Version number of the HUAWEI PPS service.
Constant Value: “20700300”
Constant
public static final int HMS_SDK_VERSION_CODE
Version number of the HMS SDK.
Constant Value: “30003300”
Constant
public static final String HMS_SDK_VERSION_NAME
Version name of the HMS SDK.
Constant Value: “3.0.3.300”

Public Methods

Method
public static < MapString, Integer > getApiMap()
Obtains the API version number of each service.

Return

typedesc
Map< String, Integer >Version number of the API of each service.
Method
public static HuaweiApiAvailability getInstance()
Returns the singleton instance of HuaweiApiAvailability.

Return

typedesc
HuaweiApiAvailabilitySingleton instance of HuaweiApiAvailability.
Method
public static  int getServicesVersionCode()
Returns the service version number.

Return

typedesc
intService version number.
Method
public static void setServicesVersionCode(int servicesVersionCode)
Sets the service version number.

Parameters

Parameter nameParameter desc
servicesVersionCodeService version number.
Method
public abstract int isHuaweiMobileServicesAvailable(Context context)
Checks whether the HMS Core (APK) is successfully installed and integrated on the device, and whether the version of the installed HMS Core (APK) is the version required by the client or is later than the required version.

Parameters

Parameter nameParameter desc
contextContext.


Return

typedesc
intStatus code indicating whether there is an error.
0: connection succeeded.
1: no HMS Core (APK) found on the device.
2: The installed HMS Core (APK) is out of date.
3: The HMS Core (APK) installed on this device is unavailable.
9: The HMS Core (APK) installed on the device is not the official version.
21: The device is too old to be supported.
Method
public abstract int isHuaweiMobileServicesAvailable(Context context, int minApkVersion)
Checks whether the HMS Core (APK) is successfully installed and integrated on the device, and whether the version of the installed HMS Core (APK) is the version required by the client or is later than the required version.

Parameters

Parameter nameParameter desc
context Context.
minApkVersionEarliest version number of the HMS required by the service.


Return

typedesc
intStatus code indicating whether there is an error.
0: connection succeeded.
1: no HMS Core (APK) found on the device.
2: The installed HMS Core (APK) is out of date.
3: The HMS Core (APK)installed on this device is unavailable.
9: The HMS Core (APK)installed on the device is not the official version.
21: The device is too old to be supported.
Method
public abstract int isHuaweiMobileNoticeAvailable(Context context)
Checks whether the HMS Core (APK) version supports notification receipt.

Parameters

Parameter nameParameter desc
contextContext.


Return

typedesc
intStatus code indicating whether there is an error.
0: connection succeeded.
2: The installed HMS is out of date.
Method
public abstract boolean isUserResolvableError(int errorCode)
Determines whether a failure can be resolved via user action.

Parameters

Parameter nameParameter desc
errorCodeError code.


Return

typedesc
booleantrue:A solution is available.
false:No solution is available.
Method
public abstract boolean isUserResolvableError(int errorCode, PendingIntent pendingIntent)
Determines whether a failure can be resolved via user action.

Parameters

Parameter nameParameter desc
errorCodeError code.
pendingIntentPending intent that can resolve the issue.


Return

typedesc
booleantrue:A solution is available.
false:No solution is available.
If pendingIntent is not null, it indicates that a solution is available. Otherwise, reference the error code.
Method
public abstract void resolveError(Activity activity, int errorCode, int requestCode)
If pendingIntent is not null, it indicates that a solution is available. Otherwise, reference the error code.

Parameters

Parameter nameParameter desc
activityIf pendingIntent is not null, it indicates that a solution is available. Otherwise, reference the error code.
errorCodeError code. If the value of isUserResolvableError is true for a result code, the system supports error rectification through user operations.
requestCodeRequest code given when calling the activity’s onActivityResult after an interaction operation.
Method
public abstract void resolveError(Activity activity, int errorCode, int requestCode, PendingIntent pendingIntent)
If an issue can be resolved through user operations, a notification or dialog box is displayed for the returned error code.

Parameters

Parameter nameParameter desc
activityActivity context used to resolve the failure. The activity’s onActivityResult method will be called after the user is done.
errorCodeError code. If the value of isUserResolvableError is true for a result code, the system supports error rectification through user operations.
requestCodeRequest code given when calling the activity’s onActivityResult after an interaction operation.
pendingIntentPending intent that can resolve the issue. The pending intent is used if pendingIntent is not null. Otherwise, the solution supported by the system is used based on errorCode.
Method
public abstract PendingIntent getResolveErrorPendingIntent(Activity activity, int errorCode)
Constructs a pending intent that can resolve the issue.

Parameters

Parameter nameParameter desc
activityActivity on the page.
errorCodeError code. If the value of isUserResolvableError is true for an error code, the system supports pending intent creation based on the error code.


Return

typedesc
PendingIntentIntent that can be used to resolve the issue through user interaction.
Method
public abstract Intent getResolveErrorIntent(Activity activity, int errorCode)
Constructs a pending intent that can resolve the issue.

Parameters

Parameter nameParameter desc
activityActivity context used to resolve the failure. The activity’s onActivityResult method will be called after the user is done.
errorCodeError code. If the value of isUserResolvableError is true for an error code, the system supports pending intent creation based on the error code.


Return

typedesc
IntentIntent that can be used to resolve the issue through user interaction.
Method
public abstract Dialog getErrorDialog(Activity activity, int errorCode, int requestCode)
Displays a notification/dialog box for the error code returned by the isHuaweiMobileServicesAvailable(Context, int) method.

Parameters

Parameter nameParameter desc
activityActivity context to use.
errorCodeError code. If the value of isUserResolvableError is true for an error code, the system supports Notification or dialog box creation based on the error code.
requestCodeRequest code, which is used for transparent transmission.


Return

typedesc
DialogNotification/Dialog box.
Method
abstract Dialog getErrorDialog(Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener onCancelListener)
Displays a notification/dialog box for the error code returned by the isHuaweiMobileServicesAvailable(Context, int) method.

Parameters

Parameter nameParameter desc
activityActivity context to use.
errorCodeError code. If the value of isUserResolvableError is true for an error code, the system supports Notification or dialog box creation based on the error code.
requestCodeRequest code, which is used for transparent transmission.
onCancelListenerProcessing when the dialog is canceled.


Return

typedesc
DialogNotification/Dialog box.
Method
public abstract String getErrorString(int errorCode )
Human-readable string of the error code returned from isHuaweiMobileServicesAvailable(Context, int).

Parameters

Parameter nameParameter desc
errorCodeError code.


Return

typedesc
StringDescription mapping the error code.
Method
public abstract boolean showErrorDialogFragment (Activity activity, int errorCode, int requestCode)
Creates and displays a dialog box for an error code.

Parameters

Parameter nameParameter desc
activityParent activity for creating the dialog.
errorCodeError code returned by the isHuaweiMobileServicesAvailable(Context, int) method.
requestCodeRequest code, which is used for transparent transmission.


Return

typedesc
booleantrue: if a dialog box is displayed; false: if no dialog box is displayed.
Method
public abstract boolean showErrorDialogFragment (Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener cancelListener)
Creates and displays a dialog box for an error code.

Parameters

Parameter nameParameter desc
activityParent activity for creating the dialog.
errorCodeError code returned by the isHuaweiMobileServicesAvailable(Context, int) method.
requestCodeRequest code, which is used for transparent transmission.
onCancelListenerProcessing when the dialog is canceled.


Return

typedesc
booleantrue: if a dialog box is displayed; false: if no dialog box is displayed.
Method
public abstract void showErrorNotification(Context context, int errorCode)
Creates and displays a dialog for an error code.

Parameters

Parameter nameParameter desc
contextSystem context.
errorCodeError code returned by isHuaweiMobileServicesAvailable(Context, int).