gpt4 book ai didi

android - Activity exported=false 在 Activity 选择器中列出

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:50:53 24 4
gpt4 key购买 nike

我有两个类似的应用程序(一个免费,一个付费)。

Activity 是用 exported="false" 定义的

    <activity
android:name=".MyActivity"
android:exported="false"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.mine" />
</intent-filter>
</activity>

当我使用来自免费应用程序的适当隐式 Intent 调用 startActivity 时,会出现 Activity 选择器。

我不明白为什么会出现来自付费应用的 Activity ,因为它是 exported="false"

我想我可以添加一个基于 URL 的 intent 过滤器,但我的问题是:为什么在读取文档时会出现来自其他应用程序的 Activity

Whether or not the activity can be launched by components of other applications

最佳答案

I don't understand why the activity from the paid app appears, since it is exported="false"

因为你有匹配的 <intent-filter> .由于您不需要 <intent-filter>对于未导出的 Activity ,只需将其删除并使用显式 Intent开始这项 Activity 时。

why does the activity from the other app appear when the doc reads...

I had the same question并被告知这是预期的行为,错误出现在我们的应用程序中,因为有一个无用的 <intent-filter> .引用 Dianne Hackborn 的话:

I would generally consider this a bug in the app -- if you have an activity that you aren't allowing other apps to launch, why the heck are you publishing an intent filter that they will match to try to launch? The security of the activity (whether it is not exported or requires a permission) is not part of intent matching. ...this scenario (publishing an activity that matches intents other applications will use but then restricting it to not be launchable by other applications) is not useful if not outright broken.

关于android - Activity exported=false 在 Activity 选择器中列出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13892721/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com