The example in this article describes how Android implements the method of adding shortcuts to launcher. Share to everyone for your reference. Specifically as follows:
When we click on the launcher of the desktop in the application, a dialog box appears prompting you to select the desktop component to add, as shown in the following illustration
When you select a shortcut, a dialog box pops up, displaying a list of the icons and names of the applications to which the shortcut is added. When we want to add an activity that adds a shortcut to this list, simply add an action to the android.intent.action.CREATE_ when the activity is registered Shortcut's intentfilter will be all right.
Shortcutaction class:
Package com.ljq.action;
Import android.app.Activity;
Import Android.os.Bundle;
/**
* Add shortcuts to launcher * *
@author jiqinlin
*/public
class Shortcutaction extends activity {
@Override public
void OnCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
}
Manifest file:
<?xml version= "1.0" encoding= "Utf-8"?> <manifest xmlns:android=
"http://schemas.android.com/apk/res/" Android "
package=" Com.ljq.action "android:versioncode=" 1 "
android:versionname=" 1.0 ">
< Application android:icon= "@drawable/icon"
android:label= "@string/app_name" >
<activity android:name =". Shortcutaction "
android:label=" @string/app_name ">
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category
android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action
android:name= " Android.intent.action.CREATE_SHORTCUT "/>
</intent-filter>
</activity>
</ application>
<uses-sdk android:minsdkversion= "7"/>
</manifest>
Run Result:
I hope this article will help you with your Android program.