在 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, andfalse
if not. Iffalse
, 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 elementfalse
. If you do so, and an app tries to call the activity, system throws anActivityNotFoundException
. 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 elementtrue
, 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/