Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress / Block BroadcastReceiver in another app

Go SMS recently updated with a new feature "Disable other message notification". The feature causes other applications listening to the incoming SMS broadcast to not fire. For example my application, Shady SMS, listens to the incoming SMS broadcast to send notifications and to actually extract and save the SMS message.

When this new feature in Go SMS is enabled, Shady does not send a notification or save the message ultimately not responding at all to the incoming SMS broadcast.

Go SMS must somehow be unregistering my application's broadcast receiver because the incoming SMS broadcast cannot be aborted. My intent filter is set to android:priority="0".

Any thoughts?

like image 476
Noah Seidman Avatar asked Jul 06 '11 17:07

Noah Seidman


People also ask

How do I stop BroadcastReceiver?

To stop receiving broadcasts, call unregisterReceiver(android. content. BroadcastReceiver) . Be sure to unregister the receiver when you no longer need it or the context is no longer valid.

What is the time limit of BroadcastReceiver in Android?

As a general rule, broadcast receivers are allowed to run for up to 10 seconds before they system will consider them non-responsive and ANR the app.

Does broadcast receiver run in background?

A broadcast receiver will always get notified of a broadcast, regardless of the status of your application. It doesn't matter if your application is currently running, in the background or not running at all.

What is the difference between service and BroadcastReceiver in Android?

A Service receives intents that were sent specifically to your application, just like an Activity. A Broadcast Receiver receives intents that were broadcast system-wide to all apps installed on the device.


1 Answers

GoSMS does have the priority set to 2147483647, but that is not "maximal" (it is the largest integer) - it is too high. Android documentation for SYSTEM_HIGH_PRIORITY is 1000 (http://developer.android.com/reference/android/content/IntentFilter.html#SYSTEM_HIGH_PRIORITY) and app priority levels should be below this - it is not a system app.

This will create unpredictable behavior. (GoSMS does not always dismiss other app notifications - the abortBroadcast only works when they get it first, usually based on installation order, but not always.) System level apps will execute, then Android will try to sort out non-system apps. If you look at the source code, the order of execution is based on priority level, but the calls to select the order of apps is not consistent for apps over 999 or for apps with the same priority level. It might be in order of installation, but system changes can result in other orders of execution (which I have seen many times with testing this).

This should really be fixed by GoSMS (and many other apps that have it wrong). Just because "priority" is an integer it does not mean that the highest value of integer makes for the highest priority level. (Just like a web URL is a string, but not all string values are valid.) Also, GoSMS should know that other apps may want to process SMS messages that are not visible to the user. If they capture it and display it to the user, that is pointless.

like image 64
Jim Avatar answered Nov 20 '22 15:11

Jim