Skip to content

Instantly share code, notes, and snippets.

View pents90's full-sized avatar

John Watkinson pents90

View GitHub Profile
@ValCanBuild
ValCanBuild / GetCpuTempAndroid.java
Created January 9, 2017 21:04
A way to get the CPU temperature from an android device by using the sys/class/thermal/temp command
public float getCpuTemp() {
Process p;
try {
p = Runtime.getRuntime().exec("cat sys/class/thermal/thermal_zone0/temp");
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
float temp = Float.parseFloat(line) / 1000.0f;