I mean the charger is plugged in but it is not charging.
Is there any indication from the system about it? I see it in "Waze" application when I get a message that the buttery stop charging because it is overheating. my application is also a heavy one that causes the same problem sometimes, so I want to know when it happens and announce a warning about it.
and another thing is -how can I tell that the battery stopped charging because of heat and not because it is 100% full?
Anyone please help me with this...
You can register a simple broadcast receiver and can monitor the battery level and charging state or can use the following sticky intent. For example:
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = context.registerReceiver(null, ifilter);
int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
float batteryPct = level / (float)scale;
And whenever you are on your desired batteryPct, you can notify user. For getting the battery temperature, you can also find information from BatteryManager.EXTRA_TEMPERATURE
i-e
val temperature = batteryStatus.getIntExtra(BatteryManager.EXTRA_TEMPERATURE)
For more details, see this android reference