Created
December 6, 2016 06:34
-
-
Save ashmeh6/e892794a72cf78bb64e356780c2ed96d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CallLogReadAndroid{ | |
public CallLogReadAndroid(){ | |
Uri allCalls = Uri.parse("content://call_log/calls"); | |
StringBuffer sb = new StringBuffer(); | |
sb.append("Call Details :"); | |
Cursor c = managedQuery(allCalls, null, null, null, CallLog.Calls.DATE + " DESC LIMIT 100"); | |
int date = c.getColumnIndex(CallLog.Calls.DATE); | |
int number = c.getColumnIndex(CallLog.Calls.NUMBER); | |
int name = c.getColumnIndex(CallLog.Calls.CACHED_NAME); | |
// String num= c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));// for number | |
// String name= c.getString(c.getColumnIndex(CallLog.Calls.CACHED_NAME));// for name | |
// String duration = c.getString(c.getColumnIndex(CallLog.Calls.DURATION));// for duration | |
int duration = c.getColumnIndex(CallLog.Calls.DURATION); | |
int type = c.getColumnIndex(CallLog.Calls.TYPE); | |
// int type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE))); | |
int i = 1; | |
while (c.moveToNext()) { | |
String phNumber = c.getString(number); | |
String callType = c.getString(type); | |
String callDate = c.getString(date); | |
String callName = c.getString(name); | |
Date callDayTime = new Date(Long.valueOf(callDate)); | |
String callDuration = c.getString(duration); | |
String dir = null; | |
int dircode = Integer.parseInt(callType); | |
switch (dircode) { | |
case CallLog.Calls.OUTGOING_TYPE: | |
dir = "OUTGOING"; | |
break; | |
case CallLog.Calls.INCOMING_TYPE: | |
dir = "INCOMING"; | |
break; | |
case CallLog.Calls.MISSED_TYPE: | |
dir = "MISSED"; | |
break; | |
} | |
sb.append("\n"+(i++)+". " + phNumber + " ( " | |
+ callName + ")__"+dir+" \nDate:--- " + callDayTime | |
+ " \nDuration in sec :--- " + callDuration); | |
sb.append("\n----------------------------------"); | |
} | |
c.close(); | |
Log.d("TAG", "init_Other: "+sb.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment