Android

acessing call logs

aucd29 2013. 10. 8. 14:39
http://malsandroid.blogspot.com/2010/06/accessing-call-logs.html

Add this to the end of your onCreate() in CallLogsActivity:
        Uri allCalls = Uri.parse("content://call_log/calls");
        Cursor c = managedQuery(allCalls, null, null, null, null);
        for(String colName : c.getColumnNames())
            Log.v(TAG, "Column Name: " + colName);

        if (c.moveToFirst())
        {
         do{
             String id = c.getString(c.getColumnIndex(CallLog.Calls._ID));
             String num = c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));
             int type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE)));

                switch (type)
                {
                    case 1: Log.v(TAG, id + ", " +num + ": INCOMING") ; break;
                    case 2: Log.v(TAG, id + ", " +num + ": OUTGOING") ;break;
                    case 3: Log.v(TAG, id + ", " +num + ": MISSED") ; break;
                }
         } while (c.moveToNext());
        }