How to get a possible idle time of the phone depending on the current battery level

I am new to Android programming environment. I am currently working on a project that deals with the battery level of the phone. I show the current battery level remaining on the phone. Now I want to display the duration of the “idle time, talk time, video playback, audio playback and web surfing” duration, which can be done based on the current battery level. Please help me. Which approach should I follow. (or) What accessible API should I use to get them.

Thank you

+4
source share
2 answers

You do not have the right to know when a user is "playing video, playing sound and surfing the web."

You can determine the talk time by looking at ACTION_PHONE_STATE_CHANGED Broadcast Intents .

I have no idea what you think about "simple." Normally, when the device is in standby mode, the CPU is off. You can roughly calculate this by watching the ACTION_SCREEN_ON and ACTION_SCREEN_OFF broadcast of Intents .

0
source

In this detailed form it’s rather complicated, I think

First of all, you need a service that receives ACTION_BATTERY_CHANGED broadcasts and records changes in battery level, so you can make rough estimates, for example: if you are now when the battery was 100% and then 50% you could get a reasonable assumption when it will be 0%.

If you want to get the estimated talk time, you need to watch ACTION_PHONE_STATE_CHANGED broadcasts, as well as the already mentioned CommonsWare. By taking recorded call times along with a low battery level, you get an idea of ​​how long you can talk with the current battery level.

+1
source

All Articles