且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安卓:java.lang.SecurityException异常:权限被拒绝:启动意图

更新时间:2021-11-13 08:31:12

您必须添加安卓出口=真正的在你的活动清单文件尝试启动。

You have to add android:exported="true" in the manifest file in the activity you are trying to start.

在android:exported文档:

安卓出口
      是否活性可以通过其他应用程序的部件推出 - true表示它可以是,和假,如果不。如果假时,活动只能被具有相同的用户ID相同的应用程序或应用程序的组成部分推出。

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.

默认值取决于该活动是否包含意图过滤器。不存在任何过滤器意味着活性可以通过指定其确切类名称仅调用。这意味着,该活动仅用于应用内部使用(因为其他人不知道类名称)。因此,在这种情况下,默认值是假。另一方面,至少一个过滤器的presence意味着该活动旨在供外部使用,所以默认值是真。

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 permission attribute).