Android 删除 未接来电 通知 _移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > Android 删除 未接来电 通知

Android 删除 未接来电 通知

 2010/11/19 9:20:12  ggggnuirgw  http://ffly.javaeye.com  我要评论(0)
  • 摘要:@OverridepublicvoidonWindowFocusChanged(booleanhasFocus){super.onWindowFocusChanged(hasFocus);//Clearnotificationsonlywhenwindowgainsfocus.Thisactivitywon't//immediatelyreceivefocusifthekeyguardscreenisaboveit.if(hasFocus){try
  • 标签: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); 
   }
?
  • 相关文章
发表评论
用户名: 匿名