abortBroadcast in BroadCastReceiver not working

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

abortBroadcast in BroadCastReceiver not working

Postby Mardaneus » Mon Feb 14, 2011 3:33 pm

I'm trying to make an application that performs some actions when an SMS with a specific text is sent to my mobile phone. The application itself does what it should do, but the abortBroadcast call in my Receiver does not prevent the default SMS application from also receiving the ordered broadcast sent by the system. I've set my applications priority to 1000000 to no avail.

If I check the code on https://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=telephony/java/com/android/internal/telephony/SMSDispatcher.java;hb=HEAD#l420 it shows that the system does dispatch an ordered broadcast, so that can't be it. Since I know that you can only abort ordered broadcasts.

PS: I'll post a code example of the manifest.xml here tonight if needed.
PS2: Does anyone know what the priority of the default SMS app is?
Edit: According to https://android.git.kernel.org/?p=platform/packages/apps/Mms.git;a=blob;f=AndroidManifest.xml;h=88c9a72ffe743960f698f97e1e08ad21981a586f;hb=HEAD the default SMS application doesn't seem to have a priority set at all.
Mardaneus
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Feb 14, 2011 10:30 am

Top

Re: abortBroadcast in BroadCastReceiver not working

Postby Mardaneus » Tue Feb 15, 2011 11:14 am

Starting to wonder this is happening because I'm setting the android:priority in the wrong spot in the AndroidManifest.xml.

What I've got now is:
Code: Select all
<receiver android:name=".SmsReceiver">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED"
                    android:priority="99999999" />
    </intent-filter>
</receiver>


But I'm thinking it should be:
Code: Select all
<receiver android:name=".SmsReceiver">
    <intent-filter android:priority="99999999">
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>


Going to try this out this evening and report back!

Edit: Tried this out and indeed this was the problem.
Mardaneus
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Feb 14, 2011 10:30 am

Re: abortBroadcast in BroadCastReceiver not working

Postby watersky » Wed Mar 30, 2011 3:57 am

Yes, "android:priority" is the attribute of <intent-filter>, not <action>.
watersky
Freshman
Freshman
 
Posts: 6
Joined: Thu Oct 22, 2009 7:36 am

Re: abortBroadcast in BroadCastReceiver not working

Postby DieBagger » Mon Apr 11, 2011 7:54 pm

Works perfectly, thx.
DieBagger
Freshman
Freshman
 
Posts: 2
Joined: Mon Mar 14, 2011 10:03 pm

Re: abortBroadcast in BroadCastReceiver not working

Postby nithzreddy » Mon May 09, 2011 1:37 pm

thanks alot..been tryin it since 2 hrs, and now its working :)
nithzreddy
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Apr 03, 2011 12:24 pm

Thank u

Postby sathishnayar » Thu Aug 25, 2011 11:31 am

Nice its very helpful thanx buddy
sathishnayar
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Aug 25, 2011 11:29 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 5 guests