目录

Classes

Class nameClass description
HuaweiApiAvailability用于校验设备上安装的HMS Core(APK)是否可用、是否需要升级。

Constant Summary




TypeNameDesc
StringSERVICES_PACKAGEHMS Core(APK)的包名。
StringSERVICES_ACTIONHMS Core(APK)导出Service的Action。
StringACTIVITY_NAMEHMS Core(APK)导出Activity的类名。
intNOTICE_VERSION_CODEclient获取公告所需要的HMS Core(APK)的版本号。
intHMS_VERSION_MIN各业务要求的最低HMS Core(APK)的版本号。
intHMS_JSON_VERSION_MINJSON版本各业务要求的最低HMS Core(APK)的版本号。
intHMS_VERSION_MAXCP所能配置的最高版本号。
intHMS_VERSION_CODE_MINCP所能配置的最低版本。
StringHMS_API_NAME_ID帐号业务API名称。
intHMS_VERSION_CODE_ID帐号业务版本号。
StringHMS_API_NAME_SNSSNS业务API名称。
intHMS_VERSION_CODE_SNSSNS业务版本号。
StringHMS_API_NAME_PAY支付业务API名称。
intHMS_VERSION_CODE_PAY支付业务版本号。
StringHMS_API_NAME_PUSHPUSH业务API名称。
intHMS_VERSION_CODE_PUSHPUSH业务版本号。
StringHMS_API_NAME_GAME游戏业务API名称。
intHMS_VERSION_CODE_GAME游戏业务版本号。
StringHMS_API_NAME_OD开发服务业务API名称。
intHMS_VERSION_CODE_OD开放服务业务版本号。
StringHMS_API_NAME_IAPIAP业务API名称。
intHMS_VERSION_CODE_IAPIAP业务版本号。
StringHMS_API_NAME_PPSPPS业务API名称。
intHMS_VERSION_CODE_PPSPPS业务版本号。
intHMS_SDK_VERSION_CODEHMS SDK版本号。
StringHMS_SDK_VERSION_NAMEHMS SDK版本名称。

Public Method Summary

Return typeMethod name
Map< String, Integer >getApiMap()
获取各个业务的API对应的版本号信息。
HuaweiApiAvailabilitygetInstance()
返回HuaweiApiAvailability的单实例。
intgetServicesVersionCode()
返回业务版本号。
voidsetServicesVersionCode(int servicesVersionCode)
设置业务版本号。
intisHuaweiMobileServicesAvailable(Context context)
验证HMS Core(APK)在设备上是否成功安装和集成,检查已经安装的HMS Core(APK)版本号是否为client所需要的版本号或比需要的更新。该类为抽象方法,需要子类实现。
intisHuaweiMobileServicesAvailable(Context context, int minApkVersion)
验证HMS Core(APK)在设备上是否成功安装和集成,检查已经安装的HMS Core(APK)版本号是否为client所需要的版本号或比需要的更新。该类为抽象方法,需要子类实现。
intisHuaweiMobileNoticeAvailable(Context context)
验证HMS Core(APK)的版本是否支持获取公告,该类为抽象方法,需要子类实现。
booleanisUserResolvableError(int errorCode)
确定是否可以通过用户操作解决错误,该类为抽象方法,需要子类实现。
voidresolveError(Activity activity, int errorCode, int requestCode)
如果可以通过用户操作解决错误,为返回的错误码显示一个通知/对话框,该类为抽象方法,需要子类实现。
voidresolveError(Activity activity, int errorCode, int requestCode, PendingIntent pendingIntent)
如果可以通过用户操作解决错误,为返回的错误码显示一个通知/对话框,该类为抽象方法,需要子类实现。
PendingIntentgetResolveErrorPendingIntent(Activity activity, int errorCode)
构建可解决方案的PendingIntent实例,该类为抽象方法,需要子类实现。
IntentgetResolveErrorIntent(Activity activity, int errorCode)
构建可解决方案的PendingIntent实例,该类为抽象方法,需要子类实现。
DialoggetErrorDialog(Activity activity, int errorCode, int requestCode)
为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误码显示一个通知/对话框。
DialoggetErrorDialog(Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener onCancelListener)
为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误码显示一个通知/对话框。
StringgetErrorString(int errorCode )
为isHuaweiMobileServicesAvailable(Context, int)返回可读的文本形式的错误代码。
booleanshowErrorDialogFragment (Activity activity, int errorCode, int requestCode)
根据错误码创建并展示对话框。
booleanshowErrorDialogFragment (Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener cancelListener)
根据错误码创建并展示对话框。
voidshowErrorNotification(Context context, int errorCode)
根据错误码创建错误Dialog并提示。

Constants

Constant
public static final String SERVICES_PACKAGE
HMS Core(APK)的包名。
Constant Value: “com.huawei.hwid”
Constant
public static final String SERVICES_ACTION
HMS Core(APK)导出Service的Action。
Constant Value: “com.huawei.hms.core.aidlservice”
Constant
public static final String ACTIVITY_NAME
HMS Core(APK)导出Activity的类名。
Constant Value: “com.huawei.hms.core.activity.JumpActivity”
Constant
public static final int NOTICE_VERSION_CODE
client获取公告所需要的HMS Core(APK)的版本号。
Constant Value: “20600000”
Constant
public static final int HMS_VERSION_MIN
各业务要求的最低HMS Core(APK)的版本号。
Constant Value: “20503000”
Constant
public static final int HMS_JSON_VERSION_MIN
JSON版本各业务要求的最低HMS Core(APK)的版本号。
Constant Value: “20701200”
Constant
public static final int HMS_VERSION_MAX
CP所能配置的最高版本号。
Constant Value: “20600000”
Constant
public static final int HMS_VERSION_CODE_MIN
CP所能配置的最低版本。
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_ID
帐号业务API名称。
Constant Value: “HuaweiID.API”
Constant
public static final int HMS_VERSION_CODE_ID
帐号业务版本号。
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_SNS
SNS业务API名称。
Constant Value: “HuaweiSns.API”
Constant
public static final int HMS_VERSION_CODE_SNS
SNS业务版本号。
Constant Value: “20503000”
Constant
Constant
public static final String HMS_API_NAME_PAY
支付业务API名称。
Constant Value: “HuaweiPay.API”
Constant
public static final int HMS_VERSION_CODE_PAY
支付业务版本号。
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_PUSH
PUSH业务API名称。
Constant Value: “HuaweiPush.API”
Constant
public static final int HMS_VERSION_CODE_PUSH
PUSH业务版本号。
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_GAME
游戏业务API名称。
Constant Value: “HuaweiGame.API”
Constant
public static final int HMS_VERSION_CODE_GAME
游戏业务版本号。
Constant Value: “20503000”
Constant
public static final String HMS_API_NAME_OD
开发服务业务API名称。
Constant Value: “HuaweiOpenDevice.API”
Constant
public static final int HMS_VERSION_CODE_OD
开放服务业务版本号。
Constant Value: “20601000”
Constant
public static final String HMS_API_NAME_IAP
IAP业务API名称。
Constant Value: “HuaweiIap.API”
Constant
public static final int HMS_VERSION_CODE_IAP
IAP业务版本号。
Constant Value: “20700300”
Constant
public static final String HMS_API_NAME_PPS
PPS业务API名称。
Constant Value: “HuaweiPPSkit.API”
Constant
public static final int HMS_VERSION_CODE_PPS
PPS业务版本号。
Constant Value: “20700300”
Constant
public static final int HMS_SDK_VERSION_CODE
HMS SDK版本号。
Constant Value: “30003300”
Constant
public static final String HMS_SDK_VERSION_NAME
HMS SDK版本名称。
Constant Value: “3.0.3.300”

Public Methods

Method
public static < MapString, Integer > getApiMap()
获取各个业务的API对应的版本号信息。

Return

typedesc
Map< String, Integer >各个业务的API对应的版本号。
Method
public static HuaweiApiAvailability getInstance()
返回 HuaweiApiAvailability 的单实例。

Return

typedesc
HuaweiApiAvailabilityHuaweiApiAvailability 的单实例。
Method
public static int getServicesVersionCode()
返回业务版本号。

Return

typedesc
int业务版本号。
Method
public static void setServicesVersionCode(int servicesVersionCode)
设置业务版本号。

Parameters

Parameter nameParameter desc
servicesVersionCode业务版本号。
Method
public abstract int isHuaweiMobileServicesAvailable(Context context)
验证HMS Core(APK)在设备上是否成功安装和集成,检查已经安装的HMS Core(APK)版本号是否为client所需要的版本号或比需要的更新。该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
context上下文。


Return

typedesc
int标识着是否有错误的状态码。
               

0: 存在可用的HMS Core(APK)

1: 在设备上没有发现HMS Core(APK)

2: 已经安装的HMS Core(APK)过时了
3: 此设备上的HMS Core(APK)已经不可用
9: 设备上安装的HMS Core(APK)是假的
21: 设备太老,不支持HMS Core(APK)。
Method
public abstract int isHuaweiMobileServicesAvailable(Context context, int minApkVersion)
验证HMS Core(APK)在设备上是否成功安装和集成,检查已经安装的HMS Core(APK)版本号是否为client所需要的版本号或比需要的更新。该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
context上下文。
minApkVersion业务要求的HMS最低版本号。


Return

typedesc
int标识着是否有错误的状态码。
               

0: 存在可用的HMS Core(APK)

1: 在设备上没有发现HMS Core(APK)

2: 已经安装的HMS Core(APK)过时了
3: 此设备上的HMS Core(APK)已经不可用
9: 设备上安装的HMS Core(APK)是假的
21: 设备太老,不支持HMS Core(APK)。
Method
public abstract int isHuaweiMobileNoticeAvailable(Context context)
验证HMS Core(APK)的版本是否支持获取公告,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
context上下文。


Return

typedesc
int标识着是否有错误的状态码。
0: HMS Core(APK)的版本支持获取公告
2: 已经安装的HMS Core(APK)过时了。
Method
public abstract boolean isUserResolvableError(int errorCode)
确定是否可以通过用户操作解决错误,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
errorCode错误码。


Return

typedesc
booleantrue:有解决方案
false:没有解决方案
Method
public abstract boolean isUserResolvableError(int errorCode, PendingIntent pendingIntent)
确定是否可以通过用户操作解决错误,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
errorCode错误码。
pendingIntent可以解决问题的pending Intent。


Return

typedesc
booleantrue:有解决方案
false:没有解决方案
判断时如果pendingIntent不为空,则认为有解决方案,否则根据错误码errorCode来判断。
Method
public abstract void resolveError(Activity activity, int errorCode, int requestCode)
如果可以通过用户操作解决错误,为返回的错误码显示一个通知/对话框,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode错误码,通过isUserResolvableError判断为true的错误码,系统支持通过用户操作解决错误。
requestCode请求码,用于交互操作后,在activity的onActivityResult回到方法中使用。
Method
public abstract void resolveError(Activity activity, int errorCode, int requestCode, PendingIntent pendingIntent)
如果可以通过用户操作解决错误,为返回的错误码显示一个通知/对话框,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode错误码,通过isUserResolvableError判断为true的错误码,系统支持通过用户操作解决错误。
requestCode请求码,用于交互操作后,在activity的onActivityResult回到方法中使用。
pendingIntent可以用于解决问题的pendingIntent,如果pendingIntent不为空,则优先使用 pendingIntent,否则使用errorCode匹配系统支持的解决方案。
Method
public abstract PendingIntent getResolveErrorPendingIntent(Activity activity, int errorCode)
构建可解决方案的PendingIntent实例,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode错误码,通过isUserResolvableError判断为true的错误码,系统支持通过错码创建pendingIntent。


Return

typedesc
PendingIntent可用于与用户交互操作解决问题的Intent。
Method
public abstract Intent getResolveErrorIntent(Activity activity, int errorCode)
构建可解决方案的PendingIntent实例,该类为抽象方法,需要子类实现。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode错误码,通过isUserResolvableError判断为true的错误码,系统支持通过错码创建pendingIntent。


Return

typedesc
Intent可用于与用户交互操作解决问题的Intent。
Method
public abstract Dialog getErrorDialog(Activity activity, int errorCode, int requestCode)
为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误码显示一个通知/对话框。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode错误码,通过isUserResolvableError判断为true的错误码,系统支持通过错码创建通知/对话框。
requestCode请求码,用于透传。


Return

typedesc
Dialog通知/对话框。
Method
abstract Dialog getErrorDialog(Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener onCancelListener)
为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误码显示一个通知/对话框。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode错误码,通过isUserResolvableError判断为true的错误码,系统支持通过错码创建通知/对话框。
requestCode请求码,用于透传。
onCancelListener用户在对话框中点击取消时的处理。


Return

typedesc
Dialog通知/对话框。
Method
public abstract String getErrorString(int errorCode )
为isHuaweiMobileServicesAvailable(Context, int)返回的错误代码的可读字符串。

Parameters

Parameter nameParameter desc
errorCode错误码。


Return

typedesc
String错误码对应的描述信息。
Method
public abstract boolean showErrorDialogFragment (Activity activity, int errorCode, int requestCode)
根据错误码创建并展示对话框。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误代码。
requestCode请求码,用于透传。


Return

typedesc
boolean如果显示对话框,则为true,否则为false。
Method
public abstract boolean showErrorDialogFragment (Activity activity, int errorCode, int requestCode, DialogInterface.OnCancelListener cancelListener)
根据错误码创建并展示对话框。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误代码。
requestCode请求码,用于透传。
onCancelListener用户在对话框中点击取消时的处理。


Return

typedesc
boolean如果显示对话框,则为true,否则为false。
Method
public abstract void showErrorNotification(Context context, int errorCode)
根据错误码创建错误Dialog并提示。

Parameters

Parameter nameParameter desc
activity页面的activity。
errorCode为isHuaweiMobileServicesAvailable(Context, int)方法返回的错误代码。