Android App dynamic Shortcut for multi flavour app -


could please configure application package 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, can configured in shortcuts.xml file, under 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, same done in 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 want achieve specify package intent, can create intent in following way:

    intent intent = new intent(sintentaction);     intent.setcomponent(new componentname("your.package.id", youractivity.class.getname()));     shortcutinfo shortcut = new shortcutinfo.builder(ctx, shortcutid)             .setshortlabel(stitle)             .setlonglabel(stitle)             .seticon(icon.createwithresource(ctx, resid))             .setintent(intent)             .build();     

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -