Android10+反垃圾短信筛选器
创始人
2024-08-20 07:30:14
0

Android 10+ 版本提供了内置的防止垃圾短信的筛选器,使用户能够自动过滤不需要的短信。以下是如何在 Android 10+ 上使用反垃圾短信筛选器的示例代码:

1.添加权限 to AndroidManifest.xml



2.添加筛选器 to AndroidManifest.xml



    


3.实现与用于数据匹配的正则表达式相匹配的 SmsReceiver.java

public class SmsReceiver extends BroadcastReceiver {
    private static final String TAG = "SmsReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
            Bundle bundle = intent.getExtras();
            if (bundle != null) {
                Object[] pdusObj = (Object[]) bundle.get("pdus");
                if (pdusObj != null) {
                    for (Object pdu : pdusObj) {
                        SmsMessage sms = SmsMessage.createFromPdu((byte[]) pdu);
                        String sender = sms.getDisplayOriginatingAddress();
                        String message = sms.getDisplayMessageBody();

                        if (!isSpam(sender, message)) {
                            // TODO Do whatever you want with the valid message
                            Log.i(TAG, "Valid SMS received, sender: " + sender + ", message: " + message);
                        } else {
                            // TODO Do whatever you want with the spam message
                            Log.i(TAG, "Spam SMS received, sender: " + sender + ", message: " + message);
                        }
                    }
                }
            }
        }
    }

    private boolean isSpam(String sender, String message) {
        // TODO Implement

相关内容

热门资讯

透视专业!德普之星辅助软件(透... 透视专业!德普之星辅助软件(透视)hh poker辅助器先试用,教程经验(的确有挂)-哔哩哔哩1、h...
hhpoker脚本!fishp... hhpoker脚本!fishpoker透视底牌(透视)方法-切实解密存在有挂1、玩家可以在fishp...
透视开挂!wpk透视插件(透视... 透视开挂!wpk透视插件(透视)wepokerplus透视脚本免费,教程经验(有挂攻略)-哔哩哔哩1...
竞技联盟破解版最新版!德州透视... 竞技联盟破解版最新版!德州透视插件(透视)教程-真是关于是有挂1、超多福利:超高返利,海量正版游戏,...
透视推荐!hh poker软件... 透视推荐!hh poker软件(透视)wepokerplus开挂,教程教材(有挂助手)-哔哩哔哩1、...
epoker有透视吗!wepo... epoker有透视吗!wepoker怎么看牌型(透视)挂-其实分享是真的挂1、这是跨平台的wepok...
透视开挂!wepoker-h5... 透视开挂!wepoker-h5下载(透视)wpk私人局有透视吗,教程烘培(有挂方法)-哔哩哔哩1、w...
wepoker开辅助能查到吗!... wepoker开辅助能查到吗!wepoker有辅助工具吗(透视)方法-果然教你真的有挂wepoker...
透视总结!佛手大菠萝有挂吗(透... 透视总结!佛手大菠萝有挂吗(透视)wepoker挂,教程妙计(有挂细节)-哔哩哔哩1、佛手大菠萝有挂...
wpk模拟器多开!We pok... wpk模拟器多开!We poker辅助器下载(透视)工具-竟然有挂有挂wpk模拟器多开!We pok...