0

I am trying to abort a particulat text if it is an MMS and is originating from a particular number. I have used abortBroadcast(). I am successful in detecting if it is an MMS or not but after that abortBroadcast does not work. Also can someone please explain how abortBroadcast works.

Here is my CODE:

 if(incomingNumber.equalsIgnoreCase("*MYNUMBER**")){
                        try {

                            abortBroadcast();

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
android_eng
  • 1,370
  • 3
  • 17
  • 40
  • Is this on KitKat? If not, are you sure `incomingNumber.equalsIgnoreCase("*MYNUMBER**")` is true? If so, what priority is your receiver set to? – Mike M. Mar 28 '14 at 22:09
  • Yes incomingNumber.equalsIgnoreCase("*MYNUMBER**") is true and the priority is set to 1000. No it is Jelly Bean – android_eng Mar 28 '14 at 22:32
  • Do you have another app installed that receives SMS/MMS? – Mike M. Mar 28 '14 at 22:38
  • Yes I have google hangout that reads the sms – android_eng Mar 28 '14 at 22:47
  • I believe that's your problem. AFAIK, the actual maximum for a Receiver's priority is 999. Yours at 1000 should correctly set it to the max, so that's good. However, IIRC, Google Hangouts actually sets its own priority to something crazy like `Integer.MAX_VALUE`, and somehow "hijacks" the priority chain. If you were to uninstall Hangouts, I believe your code would work as expected. If you can't or don't want to, I think you're kinda stuck. – Mike M. Mar 28 '14 at 22:55
  • Hi. I turned off Google Hangout. It still does not work. – android_eng Apr 04 '14 at 21:11
  • Are you sure your code is reaching the `abortBroadcast()` statement? Also, how do you know `abortBroadcast()` isn't working? – Mike M. Apr 05 '14 at 06:17
  • Yes. It reaches the method. Even after triggering abortBroadcast(), I receive the MMS. I just found out that abortBroadcast() works only for android 1.6 and that too only for SMS. Can you suggest something only for MMS and for higher versions of android OS. – android_eng Apr 07 '14 at 22:55
  • The default messaging app receives the MMS – android_eng Apr 07 '14 at 23:15

2 Answers2

0

you can do it like that

incomingnumber.contains("yournumber")
      try{

       abortbroadcast()

         }
Buggy IdioT
  • 6
  • 1
  • 12
0

Yes, you can abort broadcast for mms prior to kitkat, but kitkat does not allow you to abort broadcast unless you are default app, add android:priority="999" in your receiver' intent-filter tag like

    <receiver android:name=".MmsListener" >
        <intent-filter android:priority="999" >
      <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />

            <data android:mimeType="application/vnd.wap.mms-message" />
        </intent-filter>
    </receiver>

this should work

Arslan
  • 249
  • 2
  • 13