Outline
MSDK and the MyApp team together provide the traffic-saving update function for games; users can download the difference update package to update the game package so as to saving traffic for them.
Access Guide
1 Access configuration
1)The game has complete configuration according to the description of MSDK Android access configuration module
2)Ensure traffic-saving update configuration switch SAVE_UPDATE=true, please refer to Access configuration Step3 Configuration information
2 Registration callback
1)Interface declaration
public static void WGSetSaveUpdateObserver(WGSaveUpdateObserver observer);
2)Parameter description
Parameter name | Type | Description |
---|---|---|
observer | WGSaveUpdateObserver | traffic-saving update callback |
3)Return value
None
4)Demo code
WGPlatform.WGSetSaveUpdateObserver(new WGSaveUpdateObserver(){
@Override
public void OnCheckNeedUpdateInfo(long newApkSize, String newFeature, long patchSize, int status,
String updateDownloadUrl, int updateMethod) {
if (status == TMSelfUpdateUpdateInfo.STATUS_OK) { //Query succeeds
if (updateMethod == TMSelfUpdateUpdateInfo.UpdateMethod_NoUpdate) {
// Game TODO No update package
} else if (updateMethod == TMSelfUpdateUpdateInfo.UpdateMethod_Normal) {
// Game TODO Able to be updated in full
} else if (updateMethod == TMSelfUpdateUpdateInfo.UpdateMethod_ByPatch) {
// Game TODO Able to be incrementally updated
}
} else {
// Game TODO Query fails
}
}
@Override
public void OnDownloadAppProgressChanged(long receiveDataLen, long totalDataLen) {
long progress = receiveDataLen * 100 / totalDataLen;
// Game TODO Being download. Already complete " + progress + "%";
}
@Override
public void OnDownloadAppStateChanged(int state, int errorCode, String errorMsg) {
if (state == TMAssistantDownloadTaskState.DownloadSDKTaskState_SUCCEED) {
// Game TODO Download is completed
} else {
// Game TODO Download fails
}
}
@Override
public void OnDownloadYYBProgressChanged(String url, long receiveDataLen, long totalDataLen) {
long progress = receiveDataLen * 100 / totalDataLen;
// Game TODO Being download. Already complete " + progress + "%";
}
@Override
public void OnDownloadYYBStateChanged(String url, int state, int errorCode, String errorMsg) {
if (state == TMSelfUpdateTaskState.SelfUpdateSDKTaskState_SUCCESS) {
// Game TODO Download is completed
} else {
// Game TODO Download fails
}
}
});
5)Special description
public void OnCheckNeedUpdateInfo(long newApkSize, String newFeature, long patchSize, int status,String updateDownloadUrl, int updateMethod)
1)OnCheckNeedUpdateInfo Parameter description
Parameter name | Type | Description |
---|---|---|
newApkSize | long | new apk package's file size |
newFeature | tring | new version description |
patchSize | long | traffic-saving update package's file size |
status | int | check result TMSelfUpdateUpdateInfo.STATUS_OK : success TMSelfUpdateUpdateInfo.STATUS_CHECKUPDATE_FAILURE : failure TMSelfUpdateUpdateInfo.STATUS_CHECKUPDATE_RESPONSE_IS_NULL : response is null |
updateDownloadUrl | string | download site |
updateMethod | int | update mode TMSelfUpdateUpdateInfo.UpdateMethod_NoUpdate : no update package TMSelfUpdateUpdateInfo.UpdateMethod_Normal : full update package TMSelfUpdateUpdateInfo.UpdateMethod_ByPatch : incremental update package |
public void OnDownloadAppProgressChanged(long receiveDataLen, long totalDataLen)
2)OnDownloadAppProgressChanged Parameter description
Test name | Type | Description |
---|---|---|
receiveDataLen | long | downloaded data size |
totalDataLen | long | total data size |
public void OnDownloadAppStateChanged(int state, int errorCode, String errorMsg)
3)OnDownloadAppStateChanged Parameter description
Test name | Type | Description |
---|---|---|
state | int | state: TMAssistantDownloadTaskState.DownloadSDKTaskState_WAITING = 1; TMAssistantDownloadTaskState.DownloadSDKTaskState_DOWNLOADING = 2; TMAssistantDownloadTaskState.DownloadSDKTaskState_PAUSED = 3; TMAssistantDownloadTaskState.DownloadSDKTaskState_SUCCEED = 4; TMAssistantDownloadTaskState.DownloadSDKTaskState_FAILED = 5; TMAssistantDownloadTaskState.DownloadSDKTaskState_DELETE = 6; |
errorCode | int | errorCode |
errorMsg | string | errorMsg |
public void OnDownloadYYBProgressChanged(String url, long receiveDataLen, long totalDataLen)
4)OnDownloadYYBProgressChanged Parameter description
Test name | Type | Description |
---|---|---|
url | string | download site |
receiveDataLen | long | downloaded data size |
totalDataLen | long | to-be-downloaded data size |
public void OnDownloadYYBStateChanged(String url, int state, int errorCode, String errorMsg)
5)OnDownloadYYBStateChanged Parameter description
Parameter name | Type | Description |
---|---|---|
url | string | download site |
state | int | state: TMSelfUpdateTaskState.SelfUpdateSDKTaskState_SUCCESS = 100; TMSelfUpdateTaskState.SelfUpdateSDKTaskState_DOWNLOADING = 101; TMSelfUpdateTaskState.SelfUpdateSDKTaskState_FAILURE = 102; TMSelfUpdateTaskState.SelfUpdateSDKTaskState_GENINGNEWAPK = 103; |
errorCode | int | errorCode |
errorMsg | string | errorMsg |
3 Access workflow
Flow diagram of using MyApp traffic-saving update:
4 Refer to demos
For examples, please refer to com/example/module/submodule/My App CenterModule.java file's callWGCheckNeedUpdate(), callWGCheckYYBInstalled(), callWGStartSaveUpdate(), callWGStartCommonUpdate() methods.
Check if MyApp is installed
1 Summary
You can call WGCheckYYBInstalled() interface to check whether MyApp is installed and give the appropriate prompt; the check is not required, if your phone is not installed with MyApp, it will automatically download MyApp before update
2 Registration callback
None
3 Interface calling
1)Function description
You can call WGCheckYYBInstalled() interface to check whether MyApp is installed and give the appropriate prompt; the check is not required, if your phone is not installed with MyApp, it will automatically download MyApp before update
2)Interface declaration
public static int WGCheckYYBInstalled();
3)Parameter description
None
4)Return value
int type
0:indicate MyApp has been installed
1:indicate MyApp isn't installed
Other values indicate that a low version of MyApp is installed
5)Demo code
int ret = WGPlatform.WGCheckYYBInstalled();
switch (ret)
{
case 0: // Game TODO MyApp has been installed
break;
case 1: // Game TODO MyApp isn't installed
break;
default: // Game TODO A low version of MyApp is installed
break;
}
6)Special description
None
7)Name interpretation
None
Check if there is update
1 Summary
Query if the current app has update
2 Registration callback
Please refer toAccess GuideStep2
3 Interface calling
1)Function description
Call WGCheckNeedUpdate() interface to query if the current app has update
2)Interface declaration
public static void WGCheckNeedUpdate();
3)Parameter description
None
4)Return value
None. Call back through CheckUpdateEvent. As for the callback settings, please refer to the callback of check the game update
5)Demo code
WGPlatform.WGCheckNeedUpdate();
6)Special description
None
7)Name interpretation
None
Start traffic-saving update
1 Summary
Call WGStartSaveUpdate() interface to start traffic-saving update
2 Registration callback
Please refer toAccess GuideStep2
3 Interface calling
1)Function description
Call WGStartSaveUpdate() interface to start saving traffic update. If your phone does not install MyApp, the interface can automatically download MyApp and call back it through DownloadYYBProgressEvent and DownloadYYBStateEvent interfaces, respectively. If your phone has installed MyApp, this interface will choose whether to launch the download of MyApp based on the parameters. The download progress and status changes will be called back to the game via DownloadAppProgressEvent and DownloadAppStateEvent.
2)Interface declaration
public static void WGStartSaveUpdate(bool isUseYYB);
3)Parameter description
Parameter name | Type | Description |
---|---|---|
isUseYYB | bool | whether or not to launch MyApp to update the game; if not, update will be completed directly in the game |
4)Return value
No, the download progress and status changes will be called back to the game via DownloadAppProgressEvent and DownloadAppStateEvent
5)Demo code
WGPlatform.WGStartSaveUpdate(true);
6)Special description
If your phone does not install MyApp, the interface can automatically download MyApp and call back it through DownloadYYBProgressEvent and DownloadYYBStateEvent interfaces, respectively.
7)Name interpretation
None
FAQ
|FAQ|Traffic-saving update|Android|