來電一聲響的攔截:
就是去判斷電話鈴響跟電話掛斷的時間,如果這個兩個時間小於5秒或者幾秒就認爲是一個來電一聲響的電話,就可以從呼叫記錄中刪除這個記錄,還要在notification中顯示信息:可以創建下面的代碼
private void showNotification(String incomingNumber) {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.notification, "發現一個響一聲電話", System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
//notification.contentIntent 點擊notification的時候 激活哪個界面
Intent intent = new Intent(this,CallSmsSafeActivity.class);//要激活那個組件
intent.putExtra("number", incomingNumber);//傳遞攔截的號碼數據
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//這個必須設置
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);//這裏的FLAG_UPDATE_CURRENT說明如果一個notification如果沒有被消除掉,又來一個新的notification,他會更新這個notification
// PendingIntent.getBroadcast(context, requestCode, intent, flags);
notification.setLatestEventInfo(this, "神馬護衛提醒您", "攔截到一個騷擾電話", contentIntent);
nm.notify(0, notification);
}
噹噹前activity不存在的時候會激活當前activity並且執行oncreate方法,如果acitivity已經在任務棧的棧項存在,那麼會調用onNewIntent()方法,然後在這些方法處理直接跳出添加黑名單的對話框並把響一聲的號碼添加到輸入框中
可以打印所以的基站的信號發送信息
在cmd中進行shell(手機的)
shell>logcat -b radio