Is it possible to define static shortcuts for multiple flavors without duplicating the shortcuts.xml ? I have two flavors:
The shortcuts.xml looks like this:
<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>
The problem is that the package name in the intent can not refer to a string resource and must be hardcoded in the xml.
To also provide the shortcuts for the free flavor i have to copy the shortcuts.xml and change the targetPackage to com.test.free which is a bad solution.
Dynamic shortcuts are used for actions in apps that are context-sensitive. Context-sensitive shortcuts are tailored to the actions users perform in an app. For instance, if you build a game that allows the user to start from their current level on launch, you should update the shortcut frequently.
However, rate limiting is reset during certain events, so even background apps can call ShortcutManager methods until the rate limit is reached again. These events include the following: An app comes to the foreground. The system locale changes. The user performs the inline reply action on a notification.
Static shortcuts xml to extend the functionality of the capability. Static shortcuts are ingested by Assistant when you upload a release to Google Play Console. Since static shortcuts can only be created and updated by creating new releases, they are most useful to highlight common activities and content in your app.
I created a plugin which make it possible to use manifestPlaceholders in resources and is usable with version 3.0.0 of the android gradle plugin
https://github.com/timfreiheit/ResourcePlaceholdersPlugin
src/main/res/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="${applicationId}"/> </shortcut>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With