1. Add permis to manifest:
<Uses-Permission Android: Name = "com. Android. launcher. Permission. install_shortcut"/>
2. Create the intent of the shortcut:
Intent shortcut = new intent (
"Com. Android. launcher. Action. install_shortcut ");
Shortcut. putextra ("DUPLICATE", true );
Shortcut. putextra (
Intent. extra_shortcut_name,
Detail. getlisting (). getname ());
Export cuticonresource iconres = intent. Export cuticonresource
. Fromcontext (
Mobileprofileactivity. This,
R. drawable. mobile_android_tip_directions ctions );
Shortcut. putextra (
Intent. extra_shortcut_icon_resource,
Iconres );
Componentname comp = new componentname (
Mobileprofileactivity. This. getpackagename (),
Androidsearch. Class. getcanonicalname ());
Intent I = new intent (
Intent. action_main );
I. putextra (appconstants. key_directions_listing_id,
Detail. getlistingid ());
I. setaction (appconstants. key_action_pin_directions ctions );
I. setcomponent (COMP );
I. setflags (intent. flag_activity_clear_top );
Shortcut. putextra (intent. extra_shortcut_intent, I );
Sendbroadcast (shortcut );