iteye_8352 2011-01-04 10:18
浏览 549
已采纳

android 实现批量安装apk功能

[b]在android程序,实现了下载功能,用户可以批量下载多个apk程序,但想在用户下载完这些apk后,将这些apk进行批量安装。请问如何实现这种功能。[/b]

  • 写回答

3条回答 默认 最新

  • laopeng301 2011-01-04 17:03
    关注

    public static boolean runRootCommand(String command) {
    Process process = null;
    DataOutputStream os = null;
    try {
    process = Runtime.getRuntime().exec("su");
    os = new DataOutputStream(process.getOutputStream());
    os.writeBytes(command+"\n");
    os.writeBytes("exit\n");
    os.flush();
    process.waitFor();
    } catch (Exception e) {
    Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
    return false;
    }
    finally {
    try {
    if (os != null) {
    os.close();
    }
    process.destroy();
    } catch (Exception e) {
    // nothing
    }
    }
    return true;
    }
    }
    http://lazyhack.net/writing-an-android-root-application/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?