Android 开发服务类 05_ ApkPatchDemo

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 }

 

posted @ 2015-08-11 12:04  壬子木  阅读(333)  评论(0编辑  收藏  举报