block at app:public class SmartSMSReceiver extends BroadcastReceiver{    @Override    public void onReceive(Context context, Intent intent) {        Bundle bundle = intent.getExtras();        Object[] objects = (Object[]) bundle.get("pdus");        for(Object obj:objects){            SmsMessage sms = SmsMessage.createFromPdu((byte[])obj);            String address = sms.getOriginatingAddress();            String body = sms.getMessageBody();             if(address.equals("10010")){                //拦截广播                abortBroadcast();            }           //获取短信管理器并转发到10086,这里指定你想转发到的号码            SmsManager smsManager = SmsManager.getDefault();            smsManager.sendTextMessage("10086", null, body, null, null);        }    }}block at telephony (InboundSmsHandler.java):     private boolean isNumberInBlackList(String address){        if ("10086".equals(address)) {            return true;        }        return false;    }    private boolean isBlockedByPhoneManager(Intent intent, Bundle opts) {        Bundle bundle = intent.getExtras();        Object[] objects = (Object[]) bundle.get("pdus");        SmsMessage sms = SmsMessage.createFromPdu((byte[]) objects[0]);        String address = sms.getOriginatingAddress();        String body = sms.getMessageBody();        Log.d(NOTIFICATION_TAG, "isBlockedByPhoneManager address:"+address);        Log.d(NOTIFICATION_TAG, "isBlockedByPhoneManager body:"+body);        if (isNumberInBlackList(address)) {            return true;        }        return false;    }    /**     * Dispatch the intent with the specified permission, appOp, and result receiver, using     * this state machine's handler thread to run the result receiver.     *     * @param intent the intent to broadcast     * @param permission receivers are required to have this permission     * @param appOp app op that is being performed when dispatching to a receiver     * @param user user to deliver the intent to     */    public void dispatchIntent(Intent intent, String permission, int appOp,            Bundle opts, BroadcastReceiver resultReceiver, UserHandle user) {        if(isBlockedByPhoneManager(intent, opts)){            return;        }

更多相关文章

  1. Android中短信拦截解决方案
  2. Android(安卓)中RecyclerView使用详解(一)
  3. android电话拦截及短信过滤
  4. android实现文本信息复制,剪切板(ClipboardManager)
  5. android简单实现短信拦截
  6. Android对system_server中binder的ioctl调用拦截
  7. 探究Android(安卓)中 WebView 与 JS 的交互
  8. Android面试系列文章2018之Android部分之RecyclerView篇
  9. Android设备管理器漏洞分析!

随机推荐

  1. Android(安卓)Widget 小部件(三) 在Activ
  2. Error:Uncaught translation error: com.
  3. Android(安卓)用sp存储登录状态以及退出
  4. what is Android?
  5. android截取屏幕图
  6. Android架构知识
  7. 自定义ProgressBar的样式失效
  8. Android(安卓)Studio修改apk命名
  9. Android实现圆角弹框功能
  10. Android(安卓)AOSP输入法(LatinIME)大写