title: last outgoing call duration android
body: <p>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, </p>
  
  <pre><code>Cursor s = r.query(android.provider.CallLog.Calls.CONTENT_URI, null, null, null,CallLog.Calls.DATE + " DESC");
  </code></pre>
  
  <p>What i'm looking for is only the duration of the last call. I tried both, <code>s.moveToFirst();</code> and also <code>s.moveToLast();</code>. 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,</p>
  
  <pre><code>int duration=s.getColumnIndex(android.provider.CallLog.Calls.DURATION);
  String Duration=s.getString(duration);
  </code></pre>
  
  <p>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.</p>