OnBootReceiver:导出接收机不需要权限

时间:2021-04-15 23:20:04

I've created a BroadcastReceiver, which receives BOOT_COMPLETED.

我创建了一个BroadcastReceiver,它将接收BOOT_COMPLETED。

In my AndroidManifest.xml I've added it like so:

在我的AndroidManifest。我这样添加的xml:

<receiver
    android:name=".OnBootReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" /> 
        <action android:name="android.intent.action.QUICKBOOT_POWERON" />
    </intent-filter>
</receiver>

However, I get the warning: Exported receiver does not require permission. I've read about it on SO, but I don't fully understand it.

但是,我得到警告:导出的接收器不需要权限。我在上面读到过,但是我不完全理解。

So could someone explain to this beginner :) why I'm getting this warning, and what to do against it (and why)?

所以有人能向这个初学者解释一下:)为什么我得到这个警告,以及如何应对(为什么)?

2 个解决方案

#1


8  

The warning "Exported receiver does not require permission" means, You have an intent-filter with some action (which means by default you have android:exported="true" set and it can now receive broadcasts from ANY broadcasters outside of your application) Since it can receive broadcasts from ANY broadcasters outside of your application, it warns you by saying "Hey, are you sure ANY broadcaster can invoke you? In my opinion, it is better if you allow only those broadcasters to invoke you that has the permission you have set for this receiver through android:permission"

警告“接收器不需要出口许可”的意思是,你有一个意图过滤器和一些行动(这意味着默认你有android:出口= " true "集和它现在可以得到广播电视台以外的应用程序),因为它可以从任何广播接收广播以外的应用程序,它警告你说“嘿,你确定任何广播可以调用吗?在我看来,如果你只允许那些拥有你通过android设置的接收权限的广播公司调用你会更好

Hope this is clear!!!

希望这是清楚! ! !

#2


5  

You can remove this warning by adding android:exported="false" to the receiver tag (see this answer: https://*.com/a/11526028/757073)

您可以通过添加android:导出=“false”到接收标签来删除此警告(请参阅此答案:https://*.com/a/11526028/757073)

#1


8  

The warning "Exported receiver does not require permission" means, You have an intent-filter with some action (which means by default you have android:exported="true" set and it can now receive broadcasts from ANY broadcasters outside of your application) Since it can receive broadcasts from ANY broadcasters outside of your application, it warns you by saying "Hey, are you sure ANY broadcaster can invoke you? In my opinion, it is better if you allow only those broadcasters to invoke you that has the permission you have set for this receiver through android:permission"

警告“接收器不需要出口许可”的意思是,你有一个意图过滤器和一些行动(这意味着默认你有android:出口= " true "集和它现在可以得到广播电视台以外的应用程序),因为它可以从任何广播接收广播以外的应用程序,它警告你说“嘿,你确定任何广播可以调用吗?在我看来,如果你只允许那些拥有你通过android设置的接收权限的广播公司调用你会更好

Hope this is clear!!!

希望这是清楚! ! !

#2


5  

You can remove this warning by adding android:exported="false" to the receiver tag (see this answer: https://*.com/a/11526028/757073)

您可以通过添加android:导出=“false”到接收标签来删除此警告(请参阅此答案:https://*.com/a/11526028/757073)