My UI blocked only in 4.0.* by using clause:”Runtime.getRuntime().exec(“cat proc/meminfo”);”.
Is there something wrong in following code?
Thanks in advance.
Log:
03-27 13:37:18.545: I/MyActivity(19730): ini().429: 1332826638549
03-27 13:37:18.545: I/MyActivity(19730): ini().434: 1332826638549
03-27 13:37:18.865: D/dalvikvm(19611): GC_CONCURRENT freed 389K, 6% free 9733K/10311K, paused 1ms+2ms
Code:
Log.i(getClass().getName(), "ini().434: " + System.currentTimeMillis());
try {
Process process = Runtime.getRuntime().exec("cat proc/meminfo");//! hang here
Log.i(getClass().getName(), "ini().436: " + System.currentTimeMillis());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
Log.i(getClass().getName(), "ini().438: " + System.currentTimeMillis());
String str = bufferedReader.readLine();
totleMemory = Long.parseLong(str.replaceAll("\\s+", "").replaceAll("[a-zA-Z]", "").replaceAll(":", ""));
Log.i(getClass().getName(), "ini().441: " + System.currentTimeMillis());
totleMemory *= 1024;
} catch (Exception e) {
}
Log.i(getClass().getName(), "ini().446: " + System.currentTimeMillis());
I just opened the terminal app on my phone which is running Android 4.0+ and ran your command “cat /proc/meminfo”. I did not allow the app to have “su” or “root” permissions, running as a normal app. The command completed successfully.
So if I can run it via command line using an application running on the phone, I am sure I can do via ADB shell and most likely in Java.
I’ve used this code in my applications before:
However, when I have tried to run commands what I do not have the correct permissions to run, I have gotten that error “GC_CONCURRENT”.
Regards,