[Help] Android GUI for privoxy+polipo

Search This thread

alaa92

Member
Jul 5, 2013
18
3
Hi
How are you?
I have make simple android GUI to start privoxy and polipo binary
but my problem.How i can stop privoxy and polipo when press on stop button

i can get process id (PID) for privoxy and polipo using this code

Code:
public int findProcessIdWithPS(String str) throws IOException {
        String readLine;
        Runtime runtime = Runtime.getRuntime();
        CharSequence name = new File(str).getName();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(runtime.exec("ps " + name).getInputStream()));
        bufferedReader.readLine();
        do {
            readLine = bufferedReader.readLine();
            if (readLine == null) {
                return -1;
            }
        } while (!readLine.contains(name));
        return Integer.parseInt(readLine.split("\\s+")[1]);
    }

this code return the PID of process
then i have try kill process but not working with this code

Code:
	        Process process = Runtime.getRuntime().exec("kill -9 " + findProcessIdWithPS("privoxy"));
	         process.waitFor();
but this code not working with me

Please any help
Sorry of my English