代码如下:
public static void LauchInstall(String FilePathName, Context context)
{
chmod("777", FilePathName);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(new File(FilePathName)), "application/vnd.android.package-archive");
context.startActivity(intent);
}
//修改apk权限
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();
}
}