Why don't I get the warning on all receivers ?
Because the first two are clearly designed to be broadcast by Android. The last one is unknown, partly because you did not supply the string resource values, and possibly because they are your own unique action strings.
What permissions do I need to set for receivers meant to receive from system services to correct the warning
The correct solution is to delete the <intent-filter>
. If you are broadcasting these Intents
, or if you are wrapping an Intent
in a getBroadcast()
PendingIntent
, you do not need action strings. Use the Intent
constructor that takes the Java class object as the second parameter, and use that:
new Intent(this, BatteryMonitoringReceiver.class)
You are welcome to still attach an action string to that Intent
, if you want, but you can dump the <intent-filter>
(routing will be based on the supplied component, in this case the Java class).
Only use an <intent-filter>
when you are expecting the OS or third-party apps to initiate the Intent
themselves (executing a PendingIntent
that you created does not count).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…