this series aims to add varies app physical abilities with as little code lines inside the MainActivity. it is what the android studio IDEs should include as a default but they don't
so thank your lucky star I did it.


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.widget.Toast;

public class TempratureUtil {
    * this class gets the battery power level
    * init (in kotlin main class): val tempratureUtil = TempratureUtil();//battery level getting util //glabal var
    * step 2 : register reciever : this.registerReceiver(tempratureUtil.broadcastreceiver,tempratureUtil.intentfilter);
    * to get the level of the power use : tempratureUtil.b8TriTemp
    * */
    public IntentFilter intentfilter= new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    private float batteryTemp;
    public BroadcastReceiver broadcastreceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            //gets called every 2 seconds
            batteryTemp = (float)(intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0))/10;

    public float getBatteryTemp() {
        return batteryTemp;
    public String getB8TriTemp() {
        return batteryTemp+"";

read the class documentation

:ryu ranger: