Friday, June 10, 2011

isProcessRunning in Android - The hardway

public static boolean isProcessRunning(String paramString)
throws Exception
{
int i = 0;
Process localProcess = Runtime.getRuntime().exec("ps");
InputStream localInputStream = localProcess.getInputStream();
InputStreamReader localInputStreamReader = new InputStreamReader(localInputStream);
BufferedReader localBufferedReader = new BufferedReader(localInputStreamReader);
String str = localBufferedReader.readLine();
localBufferedReader.close();
localProcess.waitFor();

if (!str.contains(paramString))
break;

}
}

No comments:

Post a Comment