最近工作需要学习了android的 增量更新,
使用demo方式如下
package com.leepood.bsdiff;
import com.leepood.bsdiff.tools.PatchTools;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String path= Environment.getExternalStorageDirectory().getPath() ;
PatchTools.applay_patch(path+"/old.apk", path+"/new.apk",
path+"/app.patch");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
工具类代码
package com.leepood.bsdiff.tools;
public class PatchTools {
static{
System.loadLibrary("patch_tools");
}
public native static int applay_patch(String oldPackage,String newPack,String patch);
}
如果 你已经有了ndk开发环境 可以自己下载源码编译 github 源码 点击下载;
如果没有ndk开发环境 (在我的下载资源里面 刚刚上传)已经编译好的依赖包 (一个jar 一个.so),
引入jar后可直接调用方法 PatchTools.applay_patch(xx,xx,xx);