When we are applyingProgramWhen the blank head of the launcher desktop is pressed, a dialog box is displayed, prompting you to select the Desktop component to be added, as shown in
After selecting a shortcut, a dialog box is displayed, showing the icons and names of the applications to which the shortcut activity can be added. To add a shortcut activity to this list, you only need to add an android. Intent. Action. create_shortcut intentfilter when registering the activity.
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 );
}
}
Configuration 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 >
Running result