package com.util;

import java.io.File;
import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;

public class InstallUtil {
	// 安装apk
		public void installApk(File file,Activity activity) {
			chmod("777", file.getPath());
			Intent intent = new Intent();
			// 执行动作
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			intent.setAction(Intent.ACTION_VIEW);
			// 执行的数据类型
			intent.setDataAndType(Uri.fromFile(file),
					"application/vnd.android.package-archive");
			activity.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();
			}
		}
}
