Android AsyncTask Run runSuCommandAsync(String command)

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

Description

run Su Command Async

Declaration

public static Process runSuCommandAsync(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 {
    static Context con;
    public final static String SCRIPT_NAME = "surunner.sh";

    public static Process runSuCommandAsync(String command)
            throws IOException {
        DataOutputStream fout = new DataOutputStream(con.openFileOutput(
                SCRIPT_NAME, 0));//from w  w w  . j  a  va  2 s  .  co m
        fout.writeBytes(command);
        fout.close();

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

Related

  1. execute(final boolean forceSerial, final AsyncTask task, final T... args)
  2. execute(final boolean forceSerial, final AsyncTask task, final T... args)
  3. executeAsyncTask(AsyncTask task, T... params)
  4. executeAsyncTask(AsyncTask task, T... params)