【发布时间】:2012-02-15 14:12:44
【问题描述】:
我想在收到的所有 SMS 文本消息到达后读取它们并删除那些包含特定关键字的消息。我该怎么做?
【问题讨论】:
-
试试
phonegap库,把这个脚本放到android的crontab\scheduler中
我想在收到的所有 SMS 文本消息到达后读取它们并删除那些包含特定关键字的消息。我该怎么做?
【问题讨论】:
phonegap库,把这个脚本放到android的crontab\scheduler中
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
}
【讨论】: