To use your own UI for the update prompt, override the hasNewApp method in UpdateCallback. You can then use the provided UpdateAppBean to populate your dialog and use updateAppManager.download() to trigger the download process.
To monitor download progress within your custom dialog, pass a DownloadService.DownloadCallback to the download() method.
// 1. Override hasNewApp to show your own dialog
@Override
public void hasNewApp(UpdateAppBean updateApp, UpdateAppManager updateAppManager) {
showDiyDialog(updateApp, updateAppManager);
}
// 2. Inside your dialog, trigger download with a progress callback
private void showDiyDialog(final UpdateAppBean updateApp, final UpdateAppManager updateAppManager) {
// ... setup your AlertDialog ...
.setPositiveButton("升级", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
updateAppManager.download(new DownloadService.DownloadCallback() {
@Override
public void onStart() { /* Show progress UI */ }
@Override
public void onProgress(float progress, long totalSize) {
// progress is 0.00 - 1.00
}
@Override
public boolean onFinish(File file) {
// Return true to auto-install, false to just finish download
return true;
}
@Override
public void onError(String msg) { /* Handle error */ }
});
dialog.dismiss();
}
})
}