是否可以为多种口味定义静态快捷方式而无需复制shortcuts.xml?我有两种口味:
该shortcuts.xml看起来是这样的:
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:enabled="true"
android:icon="@drawable/ic_shortcut_add_photo"
android:shortcutId="new_photo"
android:shortcutLongLabel="@string/new_photo"
android:shortcutShortLabel="@string/new_photo">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="com.test.MainActivity"
android:targetPackage="com.test"/>
</shortcut>
Run Code Online (Sandbox Code Playgroud)
问题是intent中的包名称不能引用字符串资源,必须在xml中进行硬编码.
为了还为自由的味道,我必须提供快捷方式复制的shortcuts.xml并更改targetPackage到com.test.free这是一个坏的解决方案.