【发布时间】:2017-02-01 16:13:38
【问题描述】:
我正在使用 Android 的 shortcut 功能,我有以下 xml:
<shortcuts
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="some_id"
android:enabled="true"
android:icon="@drawable/ic_icon"
android:shortcutShortLabel="@string/short_label"
android:shortcutLongLabel="@string/long_label"
tools:targetApi="n_mr1">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="my.package"
android:targetClass="my.package.MainActivity" />
</shortcut>
</shortcuts>
有了这个,它就没有问题了。
我可以像在AndroidManifest.xml 中那样在快捷方式xml 文件中使用变量吗:
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
所以我想对快捷方式有相同的行为,但不知何故它不起作用:
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="${applicationId}"
android:targetClass="my.package.MainActivity" />
你知道如何在这里使用变量吗?
我想这样做的原因是我们有多个环境具有不同的包名称:my.package.test、my.package.debug、my.package.hotfix 等...
【问题讨论】:
-
任何不使用下面评论的第 3 部分库的解决方案?
-
看起来像是一个陈旧但已死的功能请求:youtrack.jetbrains.com/issue/IDEA-122253