Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 是否从应用程序中安装.zip?_Java_Android_Root - Fatal编程技术网

Java 是否从应用程序中安装.zip?

Java 是否从应用程序中安装.zip?,java,android,root,Java,Android,Root,因此,在我的应用程序中,我试图使用此工具使其在时钟恢复中闪烁.zip Runtime run = Runtime.getRuntime(); Process p = null; DataOutputStream out = null; try{ p = run.exec("su");

因此,在我的应用程序中,我试图使用此工具使其在时钟恢复中闪烁.zip

 Runtime run = Runtime.getRuntime();
                      Process p = null;
                      DataOutputStream out = null;
                      try{
                          p = run.exec("su");
                          out = new DataOutputStream(p.getOutputStream());
                          out.writeBytes("echo install_zip SDCARD:" +clickedFile.toString() +" > /cache/recovery/extendedcommand\n");
                          out.writeBytes("reboot recovery\n"); // testing
                          out.flush();

                      }catch(Exception e){
                          Log.e("FLASH", "Unable to reboot into recovery mode:", e);
                          e.printStackTrace();

                      }
它将启动恢复,但不会刷新.zip。。怎么了。。哦,如果您需要完整的.java文件,这里是:

adb
命令如下所示:

adb shell
echo 'install_zip("/sdcard/update.zip");' > /cache/recovery/extendedcommand

我也有同样的问题,但是我使用了一个ListView和一个ArrayAdapter来返回文件的完整路径。当我尝试以“SDCARD:”的形式传递路径,后跟文件的路径时,无法找到该文件,因为新版本的CWM Recovery似乎不再支持该方法。但我发现了一个简单的解决方法:

    public boolean installPackage(String pos) throws InterruptedException {
    final String location = "/emmc/" + pos.substring(11);
    Process process = null;
    try {
        process = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(process.getOutputStream());
        os = new DataOutputStream(process.getOutputStream());
        os.writeBytes("echo 'install_zip(\"" + location + "\");'" + " > /cache/recovery/extendedcommand\n");
        os.writeBytes("reboot recovery\n");
        os.writeBytes("exit\n");
        os.flush();
        return (process.waitFor() == 0);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        Log.e("FLASH:", "Unable to boot into recovery");
        e.printStackTrace();
    }
        return false;
}

我会尝试用分号将echo和重启写在一行上,比如:
echo;重新启动…
。这应该保证序列化。
    public boolean installPackage(String pos) throws InterruptedException {
    final String location = "/emmc/" + pos.substring(11);
    Process process = null;
    try {
        process = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(process.getOutputStream());
        os = new DataOutputStream(process.getOutputStream());
        os.writeBytes("echo 'install_zip(\"" + location + "\");'" + " > /cache/recovery/extendedcommand\n");
        os.writeBytes("reboot recovery\n");
        os.writeBytes("exit\n");
        os.flush();
        return (process.waitFor() == 0);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        Log.e("FLASH:", "Unable to boot into recovery");
        e.printStackTrace();
    }
        return false;
}