Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing call log in an Android device

I have created a fake caller, and one place I'm stuck is writing the call logs.

Can someone explain how to write a call log and what permissions are required for this?

I found an answer at How can I update the contents of an entry in the Call Log? but in that answer the term OsmoService is not defined. I'm not able to understand if that is a predefined class or user defined class.

Your help will be very appreciated. Thank you

like image 473
Sanjay Joshi Avatar asked Jul 30 '13 05:07

Sanjay Joshi


People also ask

How do I create a call log?

To create a call log within SalesNOW on the Android, follow these steps: Tap Contacts on the tab bar. To open the contact for whom you would like to create the call log, tap the contact record. Tap the MENU button, tap More and tap New Call Log.

Where are call logs stored in Android?

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.


1 Answers

May this help you:

Add this permission in your AndroidManifest.xml:

<uses-permission
    android:name="android.permission.READ_CALL_LOG"/>
<uses-permission
    android:name="android.permission.WRITE_CALL_LOG"/>

Code:

ContentValues values = new ContentValues();
values.put(CallLog.Calls.NUMBER, number);
values.put(CallLog.Calls.DATE, System.currentTimeMillis());
values.put(CallLog.Calls.DURATION, 0);
values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
values.put(CallLog.Calls.NEW, 1);
values.put(CallLog.Calls.CACHED_NAME, "");
values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0);
values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "");
context.getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);
like image 187
Bhavin Nattar Avatar answered Oct 07 '22 12:10

Bhavin Nattar