user1043023
user1043023

Reputation: 31

last outgoing call duration android

I have a broadcast listener which looks for any outgoing call and then starts a service upon completion of an outgoing call. The thing is within the service, I need to try and fetch the last call duration. I try querying the CallLog.Calls.CONTENT_URI using the query,

Cursor s = r.query(android.provider.CallLog.Calls.CONTENT_URI, null, null, null,CallLog.Calls.DATE + " DESC");

What i'm looking for is only the duration of the last call. I tried both, s.moveToFirst(); and also s.moveToLast();. But somehow I'm not able to get the correct value corresponding to the duration of the last outgoing call. I try and obtain the duration as,

int duration=s.getColumnIndex(android.provider.CallLog.Calls.DURATION);
String Duration=s.getString(duration);

Am i missing out on something? How can i get the last call duration alone? Because the service is started only after an outgoing call I dont have to check for the call type here.

Upvotes: 2

Views: 2647

Answers (1)

Shruti
Shruti

Reputation: 5591

add the field CallLog.Calls.DURATION to the array.

courtesy

and look at this tutorial

Upvotes: 1

Related Questions