码迷,mamicode.com
首页 > 移动开发 > 详细

Android 开发服务类 05_ ApkPatchDemo

时间:2015-08-11 13:56:31      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

APP 增量更新服务端【https://github.com/cundong/SmartAppUpdates】

 1 import com.cundong.common.Constants;
 2 import com.cundong.utils.PatchUtils;
 3 
 4 /**
 5  * 类说明:  使用旧版apk包+差分包,合并新包实例
 6  * 
 7  * @author  Cundong
 8  * @date    2014-9-6
 9  * @version 1.2
10  */
11 public class ApkPatchDemo {
12 
13     public static void main(String[] args) {
14 
15         long start = System.currentTimeMillis();
16         
17         System.out.println("开始合成新包,请等待...");
18         
19         start = System.currentTimeMillis();
20 
21         int patchResult = PatchUtils.patch(Constants.OLD_APK, Constants.OLD_2_NEW_APK, Constants.PATCH_FILE);
22 
23         long end = System.currentTimeMillis();
24 
25         System.out.println("合成新包成功:" + Constants.NEW_APK + ",耗时:" + (end - start)
26                 / 1000 + "秒,patchResult=" + patchResult);
27     }
28 
29     static {
30         System.loadLibrary("ApkPatchLibraryServer");
31     }
32 }

新旧apk包,生成差分包实例

 1 import com.cundong.common.Constants;
 2 import com.cundong.utils.DiffUtils;
 3 
 4 /**
 5  * 类说明:  新旧apk包,生成差分包实例
 6  * 
 7  * @author  Cundong
 8  * @date    2014-9-6
 9  * @version 1.2
10  */
11 public class ApkDiffDemo {
12 
13     public static void main(String[] args) {
14         
15         long start = System.currentTimeMillis();
16         
17         System.out.println("开始生成差分包,请等待...");
18 
19         int genDiff = DiffUtils.genDiff(Constants.OLD_APK, Constants.NEW_APK,
20                 Constants.PATCH_FILE);
21 
22         long end = System.currentTimeMillis();
23 
24         System.out.println("生成差分包成功:" + Constants.PATCH_FILE + ",耗时:"
25                 + (end - start) / 1000 + "秒, result=" + genDiff);
26     }
27 
28     static {
29         System.loadLibrary("ApkPatchLibraryServer");
30     }
31 }

 

Android 开发服务类 05_ ApkPatchDemo

标签:

原文地址:http://www.cnblogs.com/renzimu/p/4720612.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!