Interface Info |
|---|
public interface AppUpdateClient Provides methods related to app updates. An AppUpdateClient instance is returned when JosApps.getAppUpdateClient is called. |
Qualifier and Type | Method Name and Description |
|---|---|
void | checkAppUpdate(Context context, CheckUpdateCallBack callBack) Checks for app updates. |
void | showUpdateDialog(Context context, ApkUpgradeInfo info,boolean mustBtnOne) Displays a pop-up prompting app update. |
void | Releases callback. |
Method |
|---|
public void checkAppUpdate(Context context, CheckUpdateCallBack callBack) Checks for app updates after the app is launched and initialized or a user proactively checks for update on the app. |
Parameters
Name | Description |
|---|---|
context | Client context. |
callBack | Callback result for checking for app updates. The CheckUpdateCallBack object is defined as follows: public interface CheckUpdateCallBack {
// Status update information obtained from AppGallery.
// Refer to intent to see parameters.
void onUpdateInfo(Intent intent);
// The following method is reserved. No handling is required.
void onMarketInstallInfo(Intent intent);
// The following method is reserved. No handling is required.
void onMarketStoreError(int responseCode);
// The following method is reserved. No handling is required.
void onUpdateStoreError(int responseCode);
} |
Parameter | How to Obtain | Type | Description |
|---|---|---|---|
status | intent.getIntExtra(UpdateKey.STATUS, DEFAULT_VALUE) Note: DEFAULT_VALUE is the custom default value used when the value of UpdateKey.STATUS cannot be obtained. | int | App update status. The options are as follows:
|
rtnCode | intent.getIntExtra(UpdateKey.FAIL_CODE, DEFAULT_VALUE) Note: DEFAULT_VALUE is the custom default value used when the value of UpdateKey.FAIL_CODE cannot be obtained. | int | Result code of the update operation. The options are as follows:
|
reason | intent.getStringExtra(UpdateKey.FAIL_REASON) | String | Result code description. |
isExit | intent.getBooleanExtra(UpdateKey.MUST_UPDATE, false) | boolean | Indicates whether the user cancels the update if your app or game enables forcible updates. The options are as follows:
|
buttonStatus | intent.getIntExtra(UpdateKey.BUTTON_STATUS, DEFAULT_VALUE) Note: DEFAULT_VALUE is the custom default value used when the value of UpdateKey.BUTTON_STATUS cannot be obtained. | int | Indicates whether the user chooses to update your app or game immediately or later if your app or game does not enable forcible updates. The options are as follows:
|
info | intent.getSerializableExtra(UpdateKey.INFO) | Serializable | App update information. For details, please refer to ApkUpgradeInfo. |
Sample Code
private static class UpdateCallBack implements CheckUpdateCallBack {
public void onUpdateInfo(Intent intent) {
if (intent != null) {
// Update status.
int status = intent.getIntExtra(UpdateKey.STATUS, -1);
// Error code. You are advised to record it.
int rtnCode = intent.getIntExtra(UpdateKey.FAIL_CODE, -1);
// Failure information. You are advised to record it.
String reason = intent.getStringExtra(UpdateKey.FAIL_REASON);
// Whether to forcibly update the app. By pressing the Back button on the pop-up window, the user quits the app.
boolean isExit = intent.getBooleanExtra(UpdateKey.MUST_UPDATE, false);
// Update pop-up, where the user is offered two options: update now and update later.
int buttonStatus = intent.getIntExtra(UpdateKey.BUTTON_STATUS, -1);
// Obtain update information.
Serializable info = intent.getSerializableExtra(UpdateKey.INFO);
String updateContent = null;
if (info instanceof ApkUpgradeInfo) {
ApkUpgradeInfo upgradeInfo = (ApkUpgradeInfo) info;
// Display the update pop-up.
client.showUpdateDialog(this, upgradeInfo, false);
updateContent = upgradeInfo.toString();
Log.e(TAG, "onUpdateInfo status: " + status + ",failcause: " + rtnCode + ",isExit: "
+ isExit + ",updateInfo: " + info.toString());
}
}
}
public void onMarketInstallInfo (Intent intent){
// Reserved method. No handling is required.
}
public void onMarketStoreError ( int responseCode){
// Reserved method. No handling is required.
}
public void onUpdateStoreError ( int responseCode){
// Reserved method. No handling is required.
}
} Method |
|---|
public void showUpdateDialog(Context context, ApkUpgradeInfo info,boolean mustBtnOne) Triggers the app update pop-up manually. When detecting that a new version is available for update, an app can call this method. |
Parameters
Name | Description |
|---|---|
context | Client context. |
info | Detected update information. For details, please refer to ApkUpgradeInfo. |
mustBtnOne | Indicates whether forcible update is required for a user. The options are as follows:
|