当前位置: 代码迷 >> Android >> Android 剔除 未接来电 通知
  详细解决方案

Android 剔除 未接来电 通知

热度:546   发布时间:2016-05-01 16:00:25.0
Android 删除 未接来电 通知

    @Override    public void onWindowFocusChanged(boolean hasFocus) {        super.onWindowFocusChanged(hasFocus);        // Clear notifications only when window gains focus.  This activity won't        // immediately receive focus if the keyguard screen is above it.        if (hasFocus) {            try {                ITelephony iTelephony =                        ITelephony.Stub.asInterface(ServiceManager.getService("phone"));                if (iTelephony != null) {                    iTelephony.cancelMissedCallsNotification();//删除未接来电通知                } else {                    Log.w(TAG, "Telephony service is null, can't call " +                            "cancelMissedCallsNotification");                }            } catch (RemoteException e) {                Log.e(TAG, "Failed to clear missed calls notification due to remote exception");            }        }    }    private void resetNewCallsFlag() {//修改数据库字段,使改条通话记录不是最新通知  防止机器重新启动后又有未接电话通知        // Mark all "new" missed calls as not new anymore        StringBuilder where = new StringBuilder("type=");        where.append(Calls.MISSED_TYPE);        where.append(" AND new=1");        ContentValues values = new ContentValues(1);        values.put(Calls.NEW, "0");        this.getContentResolver().update(Calls.CONTENT_URI, values, where.toString(), null);    }
?
1 楼 huangbq 2010-11-15  
楼主能做一个删除未接来电通知的完整Demo吗?把你的代码复制过去有好多错误!ITelephony.aidl我加上了了void cancelMissedCallsNotification();方法。
2 楼 jakend 2011-08-01  
怎么都是这些代码,复制来复制去啊。
3 楼 ggggnuirgw 2011-08-01  
huangbq 写道
楼主能做一个删除未接来电通知的完整Demo吗?把你的代码复制过去有好多错误!ITelephony.aidl我加上了了void cancelMissedCallsNotification();方法。

核心代码已经给出了。至于你所说的错误。因为这个api framework里面并没有公开,是一个隐藏的api,所以你可以用反射机制,或者找个framework的架包加到你的工程里面!:)
  相关解决方案