文件名称:android studio 增量更新 bsdiff bspatch
文件大小:21.25MB
文件格式:RAR
更新时间:2020-09-25 15:53:35
android studio 增量更新 bsdiff bspatch
android studio 增量更新 bsdiff bspatch 自动更新class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) if(this.getVersionCode() < 2){ Log.d("star","当前版本号小于2进行增量更新") Log.d("star","当前版本号小于2进行增量更新${BuildConfig.VERSION_CODE}") doBspatchTask() }else{ Log.d("star","当前最新版本不需更新") Log.d("star","当前版本号小于2进行增量更新${BuildConfig.VERSION_CODE}") } } private fun doBspatchTask(){ async { val bytes = URL(URL_PATCH_DOWLOAD).readBytes() val patchFile = File(Environment.getExternalStorageDirectory(),PATCH_FILE) if(patchFile.exists()){ patchFile.delete(); } patchFile.writeBytes(bytes) var oldPath = this@MainActivity.getApkSourceDir(packageName) var newPath = NEW_APK_PATH var patchPath = patchFile.absolutePath Bspatch.bsPatch(oldPath,newPath,patchPath) Log.d("star","当前增量更新${ Bspatch.bsPatch(oldPath,newPath,patchPath)}") uiThread { this@MainActivity.installAPK(newPath) Log.d("star","newPath "+newPath) } } } }