1

How can I get the CPU tempareture on NativeActivity? I think, I should use jclass and FindClass methods or something similar. I don't know how to do it though.

0

1 Answer 1

1

You can use TYPE_AMBIENT_TEMPERATURE for battery or CPU temperature. TYPE_TEMPERATURE is the depcrecated constant.

public class TempSensorActivity extends Activity, implements SensorEventListener { private final SensorManager mSensorManager; private final Sensor mTempSensor; public TempSensorActivity() { mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); mTempSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE); } protected void onResume() { super.onResume(); mSensorManager.registerListener(this, mTempSensor, SensorManager.SENSOR_DELAY_NORMAL); } protected void onPause() { super.onPause(); mSensorManager.unregisterListener(this); } public void onAccuracyChanged(Sensor sensor, int accuracy) { } public void onSensorChanged(SensorEvent event) { } 

Click here to refer

Sign up to request clarification or add additional context in comments.

2 Comments

thank you for you advice .<br>I will try to use these calss on JNI
You have been wrong, TYPE_AMBIENT_TEMPERATURE not for CPU temperature. It's ambient temperature and have in Galaxy S4 and Moto X

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.