Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access call log for android?

Tags:

android

I would like to receive the call log. For example the number of calls made by the user, number of minutes called, etc.

How do I achieve this in android?

like image 956
3cross Avatar asked Jul 22 '11 07:07

3cross


People also ask

How can I see my full call history?

How to find Call Logs on your phone. To access your call history (i.e. a list of all of your call logs on your device), simply open your device's phone app which looks like a telephone and tap Log or Recents. You'll see a list of all incoming, outgoing calls and missed calls.

How can I get call history back on android?

Step 1. From the home screen, choose Apps or swipe up to access your Apps and then tap Phone. Step 2. Tap Recents to see your call history, in some Android phones it may be called Log, Call History, or something similar.

Where are call logs stored in Android files?

It's stored in /data/data/com. android. providers. contacts/databases/calllog.

How can I recover my call history?

Step 1: Connect the Android phone to your computer using a USB cord. Step 2: Allow USB Debugging on your Android phone. Step 3: Select the file type you need to recover - Call History. Step 4: Start to scan and find the deleted call logs on your Android phone.


2 Answers

This is for accessing phone call history:

As of Jellybean (4.1) you need the following permission:
<uses-permission android:name="android.permission.READ_CALL_LOG" />

Code:

 Uri allCalls = Uri.parse("content://call_log/calls");  Cursor c = managedQuery(allCalls, null, null, null, null);  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 type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE)));// for call type, Incoming or out going. 
like image 107
Abhinav Singh Maurya Avatar answered Oct 10 '22 15:10

Abhinav Singh Maurya


This is method used to get the Call log. Just put this method in you class and get the List of the Call Log.

Check out this

private String getCallDetails() {          StringBuffer sb = new StringBuffer();         Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null,                 null, null, null);         int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);         int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);         int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);         int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);         sb.append("Call Details :");         while (managedCursor.moveToNext()) {             String phNumber = managedCursor.getString(number);             String callType = managedCursor.getString(type);             String callDate = managedCursor.getString(date);             Date callDayTime = new Date(Long.valueOf(callDate));             String callDuration = managedCursor.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("\nPhone Number:--- " + phNumber + " \nCall Type:--- "                     + dir + " \nCall Date:--- " + callDayTime                     + " \nCall duration in sec :--- " + callDuration);             sb.append("\n----------------------------------");         }         managedCursor.close();         return sb.toString();      } 

the output looks

enter image description here

like image 21
Ashish Dwivedi Avatar answered Oct 10 '22 17:10

Ashish Dwivedi