Here is the code I have
import android.app.Activity;
> import android.content.ContentUris;
> import android.content.ContentValues;
> import android.content.Context;
> import android.database.Cursor;
> import android.net.Uri;
> import android.os.Bundle;
> import android.provider.CallLog;
> import android.util.Log;
> import android.widget.SimpleCursorAdapter;
>
>
> public class test extends Activity {
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> Uri myCall = ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI,
> 0);
>
> Cursor cur = managedQuery(myCall, null, null, null, null);
>
> String[] projection = new String[] {
> CallLog.Calls.CACHED_NAME,
> CallLog.Calls.CACHED_NUMBER_LABEL,
> CallLog.Calls.DURATION
> };
>
> Uri myCalls = CallLog.Calls.CONTENT_URI;
>
> Cursor managedCursor = managedQuery(myCalls,
> projection, // Which columns to return
> null, // Which rows to return (all rows)
> null, // Selection arguments (none)
> // Put the results in ascending order by name
> CallLog.Calls.DATE + " ASC");
> this.addToCallLog();
> this.getColumnData(managedCursor);
> }
>
>
> private void getColumnData(Cursor cur){
> if (cur.moveToFirst()) {
>
> String name;
> String phoneNumber;
> String duration;
> int nameColumn = cur.getColumnIndex(CallLog.Calls.CACHED_NAME);
> int phoneColumn =
> cur.getColumnIndex(CallLog.Calls.CACHED_NUMBER_LABEL);
> int durationColumn =
> cur.getColumnIndex(CallLog.Calls.DURATION);
> String imagePath;
>
> do {
> // Get the field values
> name = cur.getString(nameColumn);
> phoneNumber = cur.getString(phoneColumn);
> duration = cur.getString(durationColumn);
>
> //Log.i("NAMES !!!!! = ", name);
> // Log.i("Number !!!!! = ", phoneNumber);
> Log.i("duration !!!!! = ", duration);
>
>
> } while (cur.moveToNext());
>
> }
>
> }
>
> private void addToCallLog(){
>
> ContentValues values = new ContentValues();
>
> // Add Abraham Lincoln to Calls List;
> values.put(CallLog.Calls.CACHED_NAME, "Abraham Lincoln2");
> //values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "0863497543");
> values.put(CallLog.Calls.DURATION, 102);
>
> Uri uri = getContentResolver().insert(CallLog.Calls.CONTENT_URI,
> values);
>
>
> }
>
> }
>
This works in that the logcat shows that its adding the duration, however
problems include:
Not getting the phonenumber, this gives a uncaughtexception error
And the emulator crashes the Call Log app thats already on the device when
it is used after my app has run
On Tue, Dec 15, 2009 at 12:22 PM, [email protected] <[email protected]>wrote:
> Hi,
>
> I have been looking at Androids call log content provider and have
> managed to pull the data from it and display it in my own app.
>
> However I want to be able to write to the call log, is there anyway of
> doing this?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en