Android短信拦截
16lz
2021-12-04
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; }
更多相关文章
- Android中短信拦截解决方案
- Android(安卓)中RecyclerView使用详解(一)
- android电话拦截及短信过滤
- android实现文本信息复制,剪切板(ClipboardManager)
- android简单实现短信拦截
- Android对system_server中binder的ioctl调用拦截
- 探究Android(安卓)中 WebView 与 JS 的交互
- Android面试系列文章2018之Android部分之RecyclerView篇
- Android设备管理器漏洞分析!