Skip to content

Instantly share code, notes, and snippets.

@HammadMaqbool
Last active May 9, 2020 05:10
Show Gist options
  • Save HammadMaqbool/f9d3df1bad32971d3d8dde671dadf3ac to your computer and use it in GitHub Desktop.
Save HammadMaqbool/f9d3df1bad32971d3d8dde671dadf3ac to your computer and use it in GitHub Desktop.
String[] requestedColumns = { CallLog.Calls.CACHED_NUMBER_LABEL, CallLog.Calls.DURATION };
Cursor calls = managedQuery( CallLog.Calls.CONTENT_URI, requestedColumns,
CallLog.Calls.CACHED_NUMBER_LABEL+ " = ?", new String[] { "HourlyClient123" } , null);
Log.d(DEBUG_TAG, "Call count: " + calls.getCount());
int durIdx = calls.getColumnIndex(CallLog.Calls.DURATION);
int totalDuration = 0;
calls.moveToFirst();
while (!calls.isAfterLast())
{
Log.d(DEBUG_TAG, "Duration: " + calls.getInt(durIdx));
totalDuration += calls.getInt(durIdx);
calls.moveToNext();
}
Log.d(DEBUG_TAG, "HourlyClient123 Total Call Duration: " + totalDuration);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment