Android的 - 删除未接来电通知 [英] Android - remove missed call notification

查看:537
本文介绍了Android的 - 删除未接来电通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正是有消除由code未接来电通知?并以某种方式从通话记录中删除最后一个未接电话?

is there anyway to remove a missed call notification by code? And somehow remove the last missed call from call history?

推荐答案

是的,这是possible.Try这样的:

yes, it is possible.Try this:

Uri UriCalls = Uri.parse("content://call_log/calls");
Cursor cursor = getApplicationContext().getContentResolver().query(UriCalls, null, null, null, null);

读通话记录......

Reading call log entries...

if(cursor.getCount() > 0){
    cursor.moveToFirst();
    while(!cursor.isAfterLast()){
        String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER)); // for  number
        String name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME));// for name
        String duration = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DURATION));// for duration
        int type = Integer.parseInt(cursor.getString(cursor.getColumnIndex(CallLog.Calls.TYPE)));// for call type, Incoming or out going
        cursor.moveToNext();
    }
}

在通话记录中删除条目...

Deleting entry in call log...

String queryString= "NUMBER='" + number + "'";
if (cursor.getCount() > 0){
        getApplicationContext().getContentResolver().delete(UriCalls, queryString, null);
}

权限:

<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

注:请参阅此文档过电话日志的详细clearity。

Note: Please refer this doc over call log for more clearity.

使用上述code就可以得到想要的结果。

Using the above code you can get the desired result.

这篇关于Android的 - 删除未接来电通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆