【问题标题】:How can I delete texts that contain a particular keyword, on Android?如何在 Android 上删除包含特定关键字的文本?
【发布时间】:2012-02-15 14:12:44
【问题描述】:

我想在收到的所有 SMS 文本消息到达后读取它们并删除那些包含特定关键字的消息。我该怎么做?

【问题讨论】:

  • 试试phonegap库,把这个脚本放到android的crontab\scheduler中

标签: android sms


【解决方案1】:
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

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-30
    • 1970-01-01
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多