Skip to content

Instantly share code, notes, and snippets.

Avatar

John Watkinson pents90

View GitHub Profile
@ValCanBuild
ValCanBuild / GetCpuTempAndroid.java
Created Jan 9, 2017
A way to get the CPU temperature from an android device by using the sys/class/thermal/temp command
View GetCpuTempAndroid.java
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;