Android--应用静默安装

来源:互联网 发布:淘宝客的佣金怎么算 编辑:程序博客网 时间:2024/05/22 17:25
public boolean appInstall(Context context, File files) {    PrintWriter PrintWriter = null;    Process process = null;    try {        process = Runtime.getRuntime().exec("su");        PrintWriter = new PrintWriter(process.getOutputStream());        PrintWriter.println("chmod 777 " + files);        PrintWriter.println("export LD_LIBRARY_PATH=/vendor/lib:/system/lib");        PrintWriter.println("pm install -r " + files);        PrintWriter.flush();        PrintWriter.close();        int value = process.waitFor();        return value == 0 ? true : false;    } catch (Exception e) {        e.printStackTrace();    } finally {        if (process != null) {            process.destroy();        }    }    return true;}
原创粉丝点击