Wednesday, September 12, 2012

[android-developers] CallLog is not updated with the last call duration in case of shutdown.

Hello everyone,

I am quite new to Android and I found one issue (at least ,it's a problem for my app..) with the CallLog database and dying battery.

If I'm in a outgoing call and battery drops down - the phone is turned off and when is up again in the CallLog I can see the last number i have been talking to,the date when we start but unfortunately - the duration is 0,no matter how much time we spent on that call.
First ,could you confirm my observations ?Is it the same on other versions (tested on 2.2...)?
Second ,could you propose me a solution - I do not want to miss that duration,it's very important for me.



I have some ideas:
     1.Add in SharedPreferences flag - when an OutGoingCall is detected from my BroadcastReceiver it's state is "Started",when hangup is detected - change the state to "Disconnected"(Started state would be better to be set when the other part answered to my call,but I couldn't find a way to detect this moment)
2.Detect Batery_Low under some percentage (5% for instance) and if the flag says we are in call -  start writing in SharedPreferences value of the duration on every 2 seconds,so I will have an 2 seconds tolerance at the end.The duration should be taken from com.android.internal.telephony.Connection.getDurationMilis(); using reflection..Returns the number of milliseconds the call has been connected, or 0 if the call has never connected. If the call is still connected, then returns the elapsed time since connect.


I am not sure it will work,right now I saw :

public static final String ACTION_SHUTDOWN


Broadcast Action: Device is shutting down. This is broadcast when the device is being shut down (completely turned off, not sleeping). Once the broadcast is complete, the final shutdown will proceed and all unsaved data lost. Apps will not normally need to handle this, since the foreground activity will be paused as well.

What do you think -can I use this and to try to end the call - again using reflection in order to provide to the OS some resources to finish updating the CallLog?Isn't it something that the Android do in this case,normally?

Thank you in advance for your feedbacks.









--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment