【发布时间】:2013-04-13 07:26:45
【问题描述】:
我在我的 AndroidManifest 中声明了一些接收器:
<!-- no warning -->
<receiver
android:name=".receivers.TriggerMonitoringBootReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<!-- no warning -->
<receiver
android:name=".receivers.ScanResultsReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.net.wifi.SCAN_RESULTS" />
</intent-filter>
</receiver>
<!-- warning : Exported receiver does not require permission-->
<receiver
android:name=".receivers.BatteryMonitoringReceiver"
android:enabled="false">
<intent-filter>
<action android:name="@string/intent_action_setup_alarm" />
<action android:name="@string/intent_action_cancel_alarm" />
<action android:name="@string/intent_action_monitor" />
</intent-filter>
</receiver>
第一个用于接收BOOT_COMPLETED 操作。第二个是接收android.net.wifi.SCAN_RESULTS。第三个是用来接收我广播的一些动作(intent_action_monitor)和AlarmManager广播的一些动作(intent_action_setup_alarm等)。
两个问题:
- 为什么我在所有接收器上都没有收到警告?
- 我需要为要从系统服务接收的接收器设置什么权限以更正警告(我了解它的含义并且我不希望任何人使用我的接收器)? 将
exported="false"做用于引导接收器、wifi 接收器、警报接收器等?
我想过使用android:protectionLevel="signatureOrSystem"的自定义权限,但文档建议不要使用protection level 和custom permissions。那么我应该如何处理这个警告呢?
非常感谢您提供文档和/或一些代码的链接。
【问题讨论】:
标签: android broadcastreceiver android-manifest android-permissions android-broadcastreceiver