Android 6.0 internal update apk parsing error
problem
Android 6.0 internal update function, when installing apk, there is an error in parsing data.
bug location
1. It is possible that the installation package has not been downloaded successfully, or the downloaded installation package is incomplete, this needs to be checked by yourself.
2. It is possible that you have written the installation package in cache
it, which leads to unsuccessful installation under Android 6.0.
solution
1. For the location of the first bug, check whether the apk is downloaded correctly;
2. For the location of the second bug, that is the issue of permissions. Code directly
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(newFile), "application/vnd.android.package-archive");
chmod("777", newFile.getAbsolutePath());//apk放在cache文件中,需要获取读写权限
}
/**
*
* @param permission
* @param path
*/
public static void chmod(String permission, String path) {
try {
String command = "chmod " + permission + " " + path;
Runtime runtime = Runtime.getRuntime();
runtime.exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
Summary
I hope I can help you. If it helps you, just click your mouse and click a little like. I wish you a happy work and happy every day.