android - 在 Android 中导出 Activity 是否允许其他应用程序也从该 Activity 调用任何公共(public)方法?

标签 android android-manifest public android-security

在 AndroidManifest 中设置“exported=true”允许其他应用程序启动该特定 Activity 。这是否也允许其他应用程序手动调用该导出 Activity 中的任何公共(public)方法?如果是这样,执行该操作的代码会是什么样子?

最佳答案

请阅读官方documentation小心:

This element sets whether 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. If you are using intent filters, you should not set this element false. If you do so, and an app tries to call the activity, system throws an ActivityNotFoundException. Instead, you should prevent other apps from calling the activity by not setting intent filters for it.

If you do not have intent filters, the default value for this element is false. If you set the element true, the activity is accessible to any app that knows its exact class name, but does not resolve when the system tries to match an implicit intent.

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

关于android - 在 Android 中导出 Activity 是否允许其他应用程序也从该 Activity 调用任何公共(public)方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45431939/

相关文章:

java - 我怎样才能在它自己的类中创建一个私有(private)方法以便反复使用

用于 EditText 的 Android 自动填充对深色/夜间模式不友好

java - ImageView不能像按钮一样被点击

Android VpnService - 如何检查 VpnService 是否已启动?

android - 为什么我的 android 应用程序 apk 的新版本不能安装在旧版本上

java - 如何从另一个类的main方法中访问变量

android - 跟踪 Android 手机的电池高效方式

android - BackupAgent 是如何工作的?

android - 为平板电脑设计 Android 应用程序

javascript - 从另一个函数内部调用私有(private)函数