Get Last Call Duration in android

You need to use limit clause in your content query to get the last call details. So your content query will become Cursor cur = getContentResolver().query( CallLog.Calls.CONTENT_URI, null, null, null, android.provider.CallLog.Calls.DATE + ” DESC limit 1;”);

How to implement a ContentObserver for call logs

Here is the answer. Dont forget to register the content observer with this method: registerContentObserver (Uri uri, boolean notifyForDescendents, ContentObserver observer) And then you can create it like this. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getApplicationContext() .getContentResolver() .registerContentObserver( android.provider.CallLog.Calls.CONTENT_URI, true, new MyContentObserver(handler)); } class MyContentObserver extends ContentObserver { public MyContentObserver(Handler h) { super(h); } @Override … Read more