I use
public int getBatteryLevelInPercentage(){
return mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
}
to get the current battery level of an android device.
I'm looking for a possible way to 'restrict' the usage of i.e. "android.permission.ACCESS_FINE_LOCATION"
namely to change it to "android.permission. ACCESS_COARSE_LOCATION"
when the battery level starts to dip below 30%
So something like
if(getBatteryLevelInPercentage() <= 30%) { changePermission()}
I'm not sure if this is possible, or if it's even a good idea. I would appreciate greatly if you can share some of your ideas on how to deal with low battery in a good way!
Revoking permissions of an app will restart the entire app, which I'm guessing isn't what you're looking for. Instead, I suggest you limit the functionality of your app based on the received battery status.