Could you please help configure the application package for dynamic shortcuts in Android?
The application code has branding using product flavouring via build.gradle.
productFlavors {
branda {
applicationId "com.bb.branda"
...
}
brandb {
applicationId "com.bb.brandb"
...
}
...
...
}
For static shortcuts, they can be configured in the shortcuts.xml file, under the tag "targetPackage".
For eg. android:targetPackage="com.bb.branda"
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android" >
<shortcut
android:shortcutId="contact_us"
android:enabled="true"
android:icon="@drawable/home_contactus_icon"
android:shortcutShortLabel="@string/label.contactus"
android:shortcutLongLabel="@string/label.contactus"
>
<intent
android:action="contactus"
android:targetPackage="com.bb.brand"
android:targetClass="com.bb.launcher.LauncherActivity"
/>
<categories android:name="android.shortcut.conversation" />
</shortcut>
For Dynamic shortcuts, where could the same be done in the below code snippet?
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutManager shortcutManager = ctx.getSystemService(ShortcutManager.class);
ShortcutInfo shortcut = new ShortcutInfo.Builder(ctx, shortcutId)
.setShortLabel(sTitle)
.setLongLabel(sTitle)
.setIcon(Icon.createWithResource(ctx, resID))
.setIntent(new Intent(sIntentAction))
.build();
shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
}
Thanks in advance.
If what you want to achieve is specify the package for the intent, you can create the intent in the following way: