如何在 Android 上删除包含特定关键字的文本?

发布于 2025-01-05 16:49:48 字数 47 浏览 1 评论 0原文

我想在所有收到的短信到达后阅读它们,并删除那些包含特定关键字的短信。我该怎么做?

I want to read all incoming SMS text messages once they arrive and delete those that contain a particular keyword. How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只怪假的太真实 2025-01-12 16:49:48
public void onReceive(Context context, Intent intent) 
    {
        //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();        
        SmsMessage[] msgs = null;
        String msgString = "",senderinfo = ""; 


        if (bundle != null)
        {
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];            
            for (int i=0; i<msgs.length; i++){
                msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
                senderinfo += msgs[i].getOriginatingAddress();


                msgString += msgs[i].getMessageBody().toString();

            }
            //---display the new SMS message---
            Toast.makeText(context, senderinfo, Toast.LENGTH_SHORT).show();
        }
if(msgString.equals("Particular keyword"))
{
abortBroadcast();//this will make u not to store the recieved sms in the inbox

}
public void onReceive(Context context, Intent intent) 
    {
        //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();        
        SmsMessage[] msgs = null;
        String msgString = "",senderinfo = ""; 


        if (bundle != null)
        {
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];            
            for (int i=0; i<msgs.length; i++){
                msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
                senderinfo += msgs[i].getOriginatingAddress();


                msgString += msgs[i].getMessageBody().toString();

            }
            //---display the new SMS message---
            Toast.makeText(context, senderinfo, Toast.LENGTH_SHORT).show();
        }
if(msgString.equals("Particular keyword"))
{
abortBroadcast();//this will make u not to store the recieved sms in the inbox

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文