app安装,在7.0后读取文件需要权限,没有添加权限会安装失败.
/**
* 安装apk
*/
private void installAPK() {
File file = new File(apkPath);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
Uri data = Uri.fromFile(file);
intent.setDataAndType(data, "application/vnd.android.package-archive");
startActivity(intent);
}
具体解决方案可以参考 http://blog.csdn.net/yulianlin/article/details/52775160
网友评论