Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Set BroadcastReceiver Permissions (Security)

So I have 2 apps - A and B.

In A i have a BroadcastReceiver. In the receiver tag (manifest file) I specify an android:permission string (let's say com.example.app.SEND). Now B cannot send broadcasts to A anymore. Makes sense!

So what do I have to do in order for B to send broadcasts to A ? In B's manifest, I specified uses-permission tag with android:name set to the same string (com.example.app.SEND) as the receiver's android:permission but still the broadcasts won't go from B to A.

What am I doing wrong ? Or is there something else that needs to be done ?

-- Update --

Here's my app A's receiver tag:

    <receiver
        android:name="com.example.app.MyReceiver"
        android:enabled="true"
        android:exported="true"
        android:permission="com.example.BReceiver.SEND" >
        <intent-filter>
            <action android:name="com.example.BReceiver" />
        </intent-filter>
    </receiver>

And here's the uses-permission tag from my B's manifest:

<uses-permission android:name="com.pycitup.BReceiver.SEND" />
like image 340
user1437328 Avatar asked Mar 18 '23 18:03

user1437328


1 Answers

So I'd to set a custom permission for the same string like this in B's manifest:

<permission android:name="com.pycitup.BReceiver.SEND" />

Was quite straight-forward and simple. Just required a bit of reading across the web.

like image 195
user1437328 Avatar answered Apr 02 '23 04:04

user1437328