Remove All Ads from XDA
Find Your Device:
Or Continue to Thread: [Help] Android GUI for privoxy…
8th July 2014, 01:41 AM |#1  
OP Junior Member
Thanks Meter: 0
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

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()));
        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

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

Please any help
Sorry of my English