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情景模式、文件管理器 完整示例编程详解、Android程序优
  2. android 取手机号码
  3. Android 号码查询性能优化
  4. Android设备管理器漏洞分析!
  5. 基于Android系统软件管理器源码
  6. Android 监听短信接收 获取发件号码、短信内容
  7. 如何在Android上获取本机号码?

随机推荐

  1. Mysql prepare预处理的具体使用
  2. mysql索引失效的十大问题小结
  3. mysql隔离级别详解及示例
  4. Docker启动mysql配置实现过程
  5. MySQL中常见的六个约束类型详解
  6. MySQL中的回表和索引覆盖示例详解
  7. 浅谈订单重构之 MySQL 分库分表实战篇
  8. CentOS7安装MySQL 8.0.26的过程
  9. 详解MySQL主键唯一键重复插入解决方法
  10. 解决MySQL主从数据库没有同步的两种方法