how to mask missed calls to read in android?

筅森魡賤 提交于 2019-12-02 21:49:41

问题


I am working to an android app that displays the missed calls using:

String[] projection = new String[]{CallLog.Calls.NUMBER,
                CallLog.Calls.TYPE,
                CallLog.Calls.DURATION,
                CallLog.Calls.CACHED_NAME,
                CallLog.Calls._ID};

        String where = CallLog.Calls.TYPE+"="+CallLog.Calls.MISSED_TYPE+" AND " + CallLog.Calls.NEW + "=1" ;         
        Cursor c = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,projection,where, null, null);
        c.moveToFirst();    
        if(c.getCount() > 0)
        newCountersObj.missedCallCounter=c.getCount();

After checking the missed calls in my android listview I want to mark them as read in android DB. How can I do that?

Question update with the following link:

clear missed calls error in android.database.SQLite


回答1:


By setting is_read flag to true. Reference: http://developer.android.com/reference/android/provider/CallLog.Calls.html#IS_READ

Example (from ClearMissedCallsService):

    // Clear the list of new missed calls.
    ContentValues values = new ContentValues();
    values.put(Calls.NEW, 0);
    values.put(Calls.IS_READ, 1);
    StringBuilder where = new StringBuilder();
    where.append(Calls.NEW);
    where.append(" = 1 AND ");
    where.append(Calls.TYPE);
    where.append(" = ?");
    context.getContentResolver().update(Calls.CONTENT_URI, values, where.toString(),
            new String[]{ Integer.toString(Calls.MISSED_TYPE) });


来源:https://stackoverflow.com/questions/16561167/how-to-mask-missed-calls-to-read-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!