Problem Description:
You want to add a shortcut to your phone's desktop, and the desktop is a system application, which means we need to have an interface to communicate with the system. Fortunately there is a broadcast in Android, and the Android system has a broadcast receiver that receives the added shortcut broadcast. As a result, the shortcut to our application becomes simple.
Key code:
private void CreateShortcut () { Intent addintent = new Intent ("Com.android.launcher.action.INSTALL_SHORTCUT"); Gets the icon for the shortcut key parcelable icon = Intent.ShortcutIconResource.fromContext (this, r.drawable.short_cut_icon); Intent myintent = new Intent (this, shortcutactivity.class); The title of the shortcut Addintent.putextra (intent.extra_shortcut_name, "Shortcut"); Shortcut icon Addintent.putextra (Intent.extra_shortcut_icon_resource, icon); Shortcut action Addintent.putextra (Intent.extra_shortcut_intent, myintent); Send broadcast sendbroadcast (addintent); }
Add Permissions:
<uses-permission android:name= "Com.android.launcher.permission.INSTALL_SHORTCUT"/>
the author's latest development of application connection
Http://zhushou.360.cn/detail/index/soft_id/2419729?recrefer=SE_D_%E6%A3%B1%E9%95%9C
Http://www.wandoujia.com/apps/com.mastershield.personalstat
Android Create Shortcut