Restricting Android Broadcast Receiver from specific app

后端 未结 1 1974
渐次进展
渐次进展 2020-12-15 01:50

I have 2 applications.
If I use service, I can set permission so only app1 can send intent to app2:
Define permission in app2

相关标签:
1条回答
  • 2020-12-15 02:18

    The tag can also define what permission the broadcasters should have, see http://developer.android.com/guide/topics/manifest/receiver-element.html#prmsn

    I means you can protected your receiver from unauthorized broadcasts by coding like this:

    ...
    <permission android:name="com.yourapp.PERMISSION"
        android:protectionLevel="signature"
            android:label="@string/permission_label"
            android:description="@string/permission_desc">
    </permission>
    ...
    
    <receiver android:name=".MyReceiver"
        android:permission="com.yourapp.PERMISSION">
        <intent-filter>
            <action android:name="com.yourapp.ACTION" />
        </intent-filter>
    </receiver>
    ...
    
    0 讨论(0)
提交回复
热议问题