1

Is there a way to make a customView for the battery status?

Like i'm trying to make a kiosk app so the status bar is hided and i'm showing the wi-fi status with the following library, is there a way to make something for the battery or is there yet an existing library for it?

NiceToMytyuk
  • 3,644
  • 3
  • 39
  • 100
  • 1
    Check this out https://stackoverflow.com/questions/3291655/get-battery-level-and-state-in-android – Naz141 Jul 19 '18 at 12:50

1 Answers1

1

Just register broadcast receiver and get what you need in onReceive

val receiver = object : BroadcastReceiver() {
        override fun onReceive(context: Context?, intent: Intent?) {
            val battery = intent?.getIntExtra(BatteryManager.EXTRA_LEVEL, 0)
        }
        //todo
    }

registerReceiver(receiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED))