Android Shell Run runSuCommandAsync(Context context, String command)

Here you can find the source of runSuCommandAsync(Context context, String command)

Description

run Su Command Async

Declaration

public static Process runSuCommandAsync(Context context, String command)
            throws IOException 

Method Source Code

//package com.java2s;
import java.io.DataOutputStream;
import java.io.IOException;
import android.content.Context;

public class Main {
    public final static String SCRIPT_NAME = "surunner.sh";

    public static Process runSuCommandAsync(Context context, String command)
            throws IOException {
        DataOutputStream fout = new DataOutputStream(
                context.openFileOutput(SCRIPT_NAME, 0));
        fout.writeBytes(command);/*from  w  w  w  .ja va2 s.c o m*/
        fout.close();

        String[] args = new String[] {
                "su",
                "-c",
                ". " + context.getFilesDir().getAbsolutePath() + "/"
                        + SCRIPT_NAME };
        Process proc = Runtime.getRuntime().exec(args);
        return proc;
    }
}

Related

  1. findProcessIdWithPidOf(String command)
  2. findProcessIdWithPS(String command)
  3. execRootCmd(String cmd)
  4. execRootCmdSilent(String cmd)
  5. runSuCommand(Context context, String command)
  6. runSuCommandNoScriptWrapper(Context context, String command)
  7. getRoot(String loc)
  8. requestRootPermission(String path)
  9. KillProcess()