Search code examples
androidandroid-broadcast

permission is not working in Broadcast in android


Here i have registered my .Reciever_

<receiver 
    android:name=".Reciever_"
    android:permission="com.paad.MY_BROADCAST_PERMISSION">
    <intent-filter >
        <action android:name="com.paad.action.NEW_LIFEFORM_"/>
    </intent-filter>
</receiver>

and i want to use this android:permission in my code but it is not working .

I am using this permission in my code

String requiredPermission = "com.paad.MY_BROADCAST_PERMISSION";

i want to send my ordered broadcast .

sendOrderedBroadcast( new Intent("com.paad.action.NEW_LIFEFORM_") , requiredPermission ) ;

program control is not going inside OnRecieve() method ?


Solution

  • Check below link its same as like your problem....

    How to set permissions in broadcast sender and receiver in android

    In the manifest of the broadcast sender, a new permission should be declared:

    <permission android:name="com.paad.MY_BROADCAST_PERMISSION"></permission>
    
    <uses-permission android:name="com.paad.MY_BROADCAST_PERMISSION"/>
    

    its same like your code

    <receiver 
        android:name=".Reciever_"
        android:permission="com.paad.MY_BROADCAST_PERMISSION">
        <intent-filter >
            <action android:name="com.paad.action.NEW_LIFEFORM_"/>
        </intent-filter>
    </receiver>
    

    Thanks