android:exported的用法

今天在座shortcut的demo时,发现加不加android:exported="true",都能被第三方的launcher进行调用,结果就查了下,发现:

android:exported
Whether or not the activity can be launched by components of other applications — " true" if it can be, and " false" if not. If " false", the activity can be launched only by components of the same application or applications with the same user ID.

The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not 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 activity is intended for external use, so the default value is "true".

This attribute is not the only way to limit an activity's exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the permissionattribute).

default value的值是根据是否有<intent-filter>来决定的,有的话,默认值就是true,没有的话默认值就是false;两者都有的话,就以android:exported为准。

你可能感兴趣的:(android:exported的用法)