android:exported =“ true”的用途是什么?在BroadcastReceiver中 [英] What is the use of android:exported="true" in BroadcastReceiver

查看:765
本文介绍了android:exported =“ true”的用途是什么?在BroadcastReceiver中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些广播接收器在Android Manifest.xml中使用此标记 android:exported = true 进行注册。

Hi I see that some broadcast receiver use this tag android:exported="true" in Android Manifest.xml to register.

<receiver android:exported="true" android:name="com.flyingsoftgames.googleplayquery.QueryReceiver">
    <intent-filter>
       <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

android:exported = true 要在Android中注册广播接收器?

What exactly the use of android:exported="true" to register broadcast receiver in Android ?

预先感谢。

推荐答案

来自开发人员指南


android:exported
广播接收器是否可以从其外部的源接收消息application-如果可以,则为 true,否则为 false。如果为 false,则广播接收器只能接收的消息是相同应用程序的组件或具有相同用户ID的应用程序发送的消息。
默认值取决于广播接收器是否包含意图过滤器。没有任何过滤器意味着只能由指定其确切类名的Intent对象调用它。这意味着接收器仅用于应用程序内部使用(因为其他人通常不知道类名)。因此,在这种情况下,默认值为 false。另一方面,存在至少一个过滤器意味着广播接收器旨在接收系统或其他应用程序广播的意图,因此默认值为 true。

android:exported Whether or not the broadcast receiver can receive messages from sources outside its application — "true" if it can, and "false" if not. If "false", the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID. The default value depends on whether the broadcast receiver contains intent filters. The absence of any filters means that it can be invoked only by Intent objects that specify its exact class name. This implies that the receiver is intended only for application-internal use (since others would not normally know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the broadcast receiver is intended to receive intents broadcast by the system or other applications, so the default value is "true".

此属性不是限制广播接收器外部曝光的唯一方法。您还可以使用权限来限制可以向其发送消息的外部实体(请参阅权限属性)。

This attribute is not the only way to limit a broadcast receiver's external exposure. You can also use a permission to limit the external entities that can send it messages (see the permission attribute).

这篇关于android:exported =“ true”的用途是什么?在BroadcastReceiver中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆