I’m trying to make a visible battery indicator for my Android App, So far I can get this to read the battery level on my Android device as a UI text but I want to use a fill image as a battery indicator. Can anyone help me out with how to do this if it’s possible.
int GetBatteryLevel()
{
try
{
string CapacityString = System.IO.File.ReadAllText("/sys/class/power_supply/battery/capacity");
BatLevelText.text = ("BATTERY LEVEL: " + CapacityString);
return int.Parse(CapacityString);
}
catch (System.Exception e)
{
//Debug.Log("Failed to read battery power; " + e.Message);
//print("Bat Life: " + e.Message);
testText.text = e.Message.ToString();
}
return -1; //if no value is found
}