我正在编写自己的短信信使,我需要完全禁止默认股票信使发出的新短信通知。可以肯定的是,我正在拦截传入的 SMS 通知并Broadcast
通过中止BroadcastReceiver.abortBroadcast()
,例如:
public void onReceive(Context context, Intent intent) {
Map<String, String> msgs = retrieveMessages(intent);
for (String address : msgs.keySet()) {
String msg = msgs.get(address);
Log.i(TAG, "New sms received=" + msg);
//saving message in phone
Message message = Message.createIncomingMessage(address, msg);
message.setSeen(1); ////mark message seen, so stock messenger couldn't arose notification
message.setRead(1); //mark message read, so stock messenger couldn't report it as unread
message.setUnread(true); //mark message unread for our messenger
message = Me.getMe().getMessageDAO().save(context, message); //saving message
SmsReceiver.updateNotification(context, message, true, true); //raise notification from "our" messenger
}
//aborting default broadcast, since everything already done and no need to do more
this.abortBroadcast();
}
一切都按计划进行。但是,每当我Me.getMe().getMessageDAO().save(context, message);
在几秒钟内通过股票信使将新短信插入数据库时,就会以某种方式收到有关数据库中新消息的通知,并再次发出通知。
问题是:如何抑制这个通知?