android xml $,在Android快捷方式中使用变量功能xml?

我正在使用Android的shortcut功能,我有以下xml:

xmlns:tools="http://schemas.android.com/tools"

xmlns:android="http://schemas.android.com/apk/res/android">

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">

android:action="android.intent.action.MAIN"

android:targetPackage="my.package"

android:targetClass="my.package.MainActivity" />

有这样的,它没有问题.

我可以在快捷方式xml文件中使用变量,例如在AndroidManifest.xml中我可以这样做:

所以我想对快捷方式有相同的行为,但不知何故它不起作用:

android:action="android.intent.action.MAIN"

android:targetPackage="${applicationId}"

android:targetClass="my.package.MainActivity" />

你知道如何在这里使用变量吗?

我想这样做的原因是我们有多个具有不同包名的环境:my.package.test,my.package.debug,my.package.hotfix等…

解决方法:

我创建了一个插件,可以在资源中使用manifestPlaceholders,并且可以与android gradle插件的3.0.0版一起使用

的src / main / RES / shortcuts.xml:

android:action="android.intent.action.VIEW"

android:targetClass="com.test.MainActivity"

android:targetPackage="${applicationId}"/>

标签:android,shortcuts

来源: https://codeday.me/bug/20190623/1266177.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值