【发布时间】:2021-07-15 11:26:06
【问题描述】:
我的应用检测是否通过queryIntentActivities 安装了某个应用。由于我的应用程序以 api 级别 30 为目标,因此 stopped working 因为我缺少一些清单声明。
在this example 他们直接定义包名。但是我要查询的应用程序因每个构建变体而异。所以最好使用字符串资源。然而这似乎是不可能的。
示例
<manifest package="com.example.game">
<queries>
<package android:name="com.example.store" />
<package android:name="com.example.services" />
</queries>
...
</manifest>
我想要什么
<manifest package="com.example.game">
<queries>
<package android:name="@string/store_app" />
<package android:name="@string/services_app" />
</queries>
...
</manifest>
其他文件
<string name="store_app">com.example.store</string>
<string name="services_app">com.example.services</string>
如何使用字符串资源
【问题讨论】:
-
您可以像示例中一样直接使用包名称,但会覆盖每个构建的清单文件,因此每个构建都会有正确的查询列表。
标签: android android-intent android-manifest android-11