parent
e17de8669e
commit
0b1c4b6de0
@ -1,16 +0,0 @@ |
||||
package io.legado.app.utils |
||||
|
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.content.IntentFilter |
||||
import android.os.BatteryManager |
||||
|
||||
object BatteryUtils { |
||||
|
||||
fun getLevel(context: Context): Int { |
||||
val iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED) |
||||
val batteryStatus = context.registerReceiver(null, iFilter) |
||||
|
||||
return batteryStatus?.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) ?: -1 |
||||
} |
||||
} |
Loading…
Reference in new issue