Suppress/Block Broadcastreceiver in Another App

Suppress / Block BroadcastReceiver in another app

My intent filter is set to android:priority="0".

This is the lowest possible priority. All other applications will get their chance first before it comes to you. Quoting the documentation:

It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)

So, they are simply calling abortBroadcast(). They probably have their priority jacked to the roof.

Android disable BroadcastReceiver when app is shut down

There is already an answer to that.

Basically you disable the Broadcast Receiver via the PackageManager in the onDestroy method of your Application class and enable it again in the onCreate Method of your Application class.

Broadcast receiver stop triggering when swipe clear the app

In main app start/stop the service

Intent service = new Intent(context, MyService.class);
context.startService(service);
...
Intent service = new Intent(context, MyService.class);
context.stopService(service);

service

  public class MyService extends Service
{
private static BroadcastReceiver m_Receiver;

@Override
public IBinder onBind(Intent arg0)
{
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}

@Override
public void onCreate()
{
Receiver();
}

@Override
public void onDestroy()
{
unregisterReceiver(m_Receiver);
}

private void Receiver()
{
m_Receiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
//place all ur stuff here
}
}

}
}

prevent other apps from sending broadcasts to my broadcastReceiver

Every reciever with exported tag set to false will only receive broadcasts sent from its own application process.

so it will be:

<receiver android:name=".MyReceiver"
android:exported="false">
<intent-filter>
<action android:name="MyAction"/>
</intent-filter>
</receiver>


Related Topics



Leave a reply



Submit