how get current CPU temperature programmatically in all Android Versions?

前端 未结 1 480
感动是毒
感动是毒 2021-01-17 17:32

I am using this code for get current CPU Temperature :

and saw it too

 private float getCurrentCPUTemperature() {
    String file = readFile(\"/sys/         


        
相关标签:
1条回答
  • 2021-01-17 18:04

    Divide the value by 1000 on newer API:

    float cpu_temp = getCurrentCPUTemperature();
    if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        cpu_temp = cpu_temp / 1000;
    }
    

    I'd just wonder where batteryTemp comes from and how it should be related to the CPU.

    0 讨论(0)
提交回复
热议问题