Post Reply

[Help] Android GUI for privoxy+polipo

8th July 2014, 01:41 AM   |  #1  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Jul 2013
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
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Java for Android App Development by ThreadRank