tags:

views:

37

answers:

2

Hi !!

I am new to the android programming environment. I am currently working on a project which deals with the user's phone battery level.I am showing the current battery level left on the phone.now i want to display the amount of duration of "idle time, talk time, video playback, audio playback and web surfing" that can be done based on the current battery level.Please help me.What kind of approach shall i follow.(or) What available API shall i use to get those.

Thanking You

A: 

You have no right to know when the user is "video playback, audio playback and web surfing".

You can determine talk time by watching for ACTION_PHONE_STATE_CHANGED broadcast Intents.

I have no idea what you think "idle time" is. Usually, when the device is idle, the CPU is off. You can roughly calculate this by watching for ACTION_SCREEN_ON and ACTION_SCREEN_OFF broadcast Intents.

CommonsWare
A: 

In this detailed way it's quite complicated I think

First of all you would need a service which is receiving ACTION_BATTERY_CHANGED broadcasts and record the battery level changes - so you're able to make rough estimations, for example: if you now when the battery was on 100% and then on 50% you could make an educated guess when it will be 0%.

If you want to want to get an estimated talk time you need to watch for ACTION_PHONE_STATE_CHANGED broadcasts as well as CommonsWare already mentioned. Taking recorded call times together with the dropped battery level would give you an idea about how long it's possible to talk with the current battery level.

Martin