Search code examples
androidbroadcastreceiveralarmmanagerintentfilter

Why does receiver for AlarmManager has no Intent Filter?


I'm using the Alarm Manger in my project and i have this declaration in my Manifest. Everything is working Perfect and fine but I have this query in my mind that Why does the following

 <receiver android:name="wokerClasses.alarmReceiver"></receiver>

Declaration for the class that handles the receiver in its onReceive() has no intent-Filter? I want to understand that how does the system invoke and recognize that this specific receiver and Why no other sendBroadcast() invoke this receiver.


Solution

  • how does the system invoke and recognize that this specific receiver

    You are creating a PendingIntent, using getBroadcast(), wrapping an Intent that identifies this BroadcastReceiver. That Intent is an explicit Intent, one that identifies the specific Java class of the component. The PendingIntent allows you to selectively grant other processes — such as the Android core process managing alarm events — to be able to send a broadcast to this receiver, even though that receiver is not exported.

    Why no other sendBroadcast() invoke this receiver.

    That receiver is not exported; nothing else on the system can send it a broadcast, except:

    • Your own code
    • Anyone holding a PendingIntent that you give them