该应用程序有一些 Activity ,一些仅在更高版本上运行。但是由于 Activity 支持 intent-filter
的 mimeType
,所以我无法控制它的启动。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
就像具有此 intent-filter
的 Activity 可以由较低的版本启动而不是必须的。例如:该 Activity 必须在版本 11 及更高版本中运行,但 android 仍会在较低版本的图像选择器对话框中显示它。有没有办法避免这种情况?
最佳答案
如果您只寻找 XML 配置,我可以向您推荐方法,它是如何在 Android API 演示中完成的。
他们在 AndroidManifest 中将 Activity
声明为禁用或启用,具体取决于 API 版本,如 android:enabled="@bool/atLeastHoneycomb"
,其中 @bool/atLeastHoneycomb
只是一个标志,在 values-v11
中设置为 true,在默认的 values
文件夹中设置为 false(您可以查看 Android API 演示,如我之前说过,了解更多详情)。
关于android - Activity 的最低 SDK 版本支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17907449/