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
Android Studio: Creating Landscape Layouts
How to Get Number of Lines of Textview
Validation Allow Only Number and Characters in Edit Text in Android
Apache Http Connection with Android 6.0 (Marshmallow)
How to Decompile an APK or Dex File on Android Platform
Android Fragments: When to Use Hide/Show or Add/Remove/Replace
How to Align Android Toolbar Menu/Icons to the Left Like in Google Maps App
Animate Progressbar Update in Android
How to Install Android Market App on the Emulator
Authentication Using Facebook at First and Then Google Causes an Error in Firebase for Android
Getting Nosuchfielderror Instance Org/Apache/Http/Message/Basicheadervalueparser
Sqlite Exception No Such Column When Trying to Select
Android Mediarecorder - "Start Failed: -19"
View the Task's Activity Stack