3

I have a broadcastReceiver registered in manifest that receives broadcasts sent from one of my services with a custom action. I have it already working but for security reasons i want to prevent other apps from sending fake broadcast to my receiver. How can i do that?

Manifest

<receiver android:name=".MyReceiver">
    <intent-filter>
        <action android:name="MyAction"/>
    </intent-filter>
</receiver>
Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87

2 Answers2

3

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>
Hojjat Imani
  • 333
  • 1
  • 15
0

As another solution i found that i can use permissions.

more on here

Kushal
  • 8,100
  • 9
  • 63
  • 82