0
我做了一些程序,它從手機中刪除不需要的短信(通過特殊的過濾器)。Android abortBroadcast()的作品奇怪
它使用aborBroadcast()來停止SMS。
在模擬器中,它工作正常,在一些手機上(我使用Android 2.2測試過)。
但在一些手機(三星,2.3.3),它不會停止短信。在我的程序被刪除後,手機又收到了所有的短信,終止了。
我android.manifest代碼:
<receiver android:name=".SmsHandler" >
<intent-filter android:priority="2147483647" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
我的處理代碼:
if msgText.contains(GlobalVars.getInstance().getFilterText())) {
abortBroadcast();
}
也許,有人能指點我?
我檢查了這個簡單的代碼: if(isOrderedBroadcast())sendToLog(「SMSIL」,「Ordered。」); else sendToLog(「SMSIL」,「未命令。」); 並且廣播是有序的。 – Andrey
奇怪。順便說一句,我試圖放棄在2.3模擬器上的廣播,它不起作用。我很肯定,你不能放棄這個廣播。正如你所提到的,它可能在少數設備上工作。 –
但是我注意到了一件事,如果您將優先級設置爲1000,則http://developer.android.com/reference/android/content/IntentFilter.html#SYSTEM_HIGH_PRIORITY,它似乎適用於它不是它的仿真器。魔法!!!! –