Learn about how to use the relevant APIs of Android update SDK.
MPaaSCheckVersionService API
checkNewVersion
Check if a new version is available. This method starts an asynchronous task to check the updates and calls the relevant callback method of MPaaSCheckCallBack
whether or not a new version is available.
void checkNewVersion(Activity activity)
setIntervalTime
Set the interval of reminder:
void setIntervalTime(long interval202)
3 days by default, in milliseconds.
setMPaasCheckCallBack
An example of the callback to be called when setting the update SDK for checking updates:
void setMPaaSCheckCallBack(MPaaSCheckCallBack mPaaSCheckCallBack)
installApk
To install the package of the new version, in MPaaSCheckCallBack.alreadyDownloaded
method, you can call:
void installApk(String filePath)
void installApk(ClientUpgradeRes res)
update
To download the package of the new version, in MPaaSCheckCallBack.showUpgradeDialog
method, you can call:
void update(ClientUpgradeRes res)
MPaaSCheckCallBack API
startCheck
Called after calling the update checking interface. In this method, you can prompt the users that the checking is in loading:
void startCheck()
isUpdating
Called when the update checking interface is repeatedly called:
void isUpdating()
onException
Called when exceptions occur in update checking:
void onException(Throwable throwable)
dealDataInValid
Called if the returned update information is valid:
void dealDataInValid(Activity activity, ClientUpgradeRes result)
dealHasNoNewVersion
Called if the returned update information is invalid:
void dealHasNoNewVersion(Activity activity, ClientUpgradeRes result)
alreadyDownloaded
Called if the new version package has already been downloaded: You can prompt users to install this package at this time. If users choose to install, then MPaaSCheckVersionService.installApk
method is called for installation:
void alreadyDownloaded(Activity activity, ClientUpgradeRes result)
showUpgradeDialog
Called when a new version is available, but the package is not downloaded. You can prompt and ask users whether to update, if users choose to update, then MPaaSCheckVersionService.update
method is called for triggering download:
void showUpgradeDialog(Activity activity, ClientUpgradeRes result)
onLimit
Called when a new version is available, but the time from the last checking is less than the set interval. It is valid only when the configuration is Single reminder.
void onLimit(Activity activity, ClientUpgradeRes result, String reason)