gpt4 book ai didi

Android:导出的接收者属性是什么意思?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:37:40 37 4
gpt4 key购买 nike

   <receiver
android:name="MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

不知道是否需要通知。如果这是真的,任何应用程序都可以通过这些操作调用我的接收器?因此,如果我将其设置为 false,系统可以将操作发送到我的接收器吗?

最佳答案

I don't understand if it's needed to be notified. If it were true any app could call my receiver with those actions? So If I make it false the system can send the actions to my receiver?

实际上,其他应用无法“调用您的接收器”。其他app只能发广播Intent秒。然后系统将调用所有已注册的接收者。

一般来说,您不必为此担心。大多数这些广播Intent s 受到保护,因此只有系统应用程序才能广播它们。另一个应用程序尝试广播 BOOT_COMPLETED ,例如,将被忽略。如果你的 BroadcastReceiver 会发生什么被流氓应用程序触发,因为它广播 CONNECTIVITY_CHANGE ?可能什么都没有,因为您的应用程序应该检查 onReceive() 中的真实连接状态无论如何,如果没有任何变化,您可以忽略它。

此外,您无需指定 android:enabled="true"因为这是默认状态。您也不需要指定 android:exported="true"因为你有一个 <intent-filter>附在你的<receiver>自动设置 android:exportedtrue .

关于Android:导出的接收者属性是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38346567/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com