The Android operating system displays an activity for <intent-filter> with the following properties in the Application Manager (Launcher), which typically corresponds to an application's main task.
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
In addition, if the user wants to add a shortcut to the appliance's home screen, the app's icon can be launcher in the Android system, and it will automatically add a shortcut to the home screen for the application. The name and icon are the same as in launcher.
In addition to supporting shortcuts to applications (primary activity), Android can define shortcuts to any activity in application on the home screen.
For example, there is a function in your application users may often use, such as the map to query the address, under normal circumstances users need to start the main activity, may need to go through a few menu options or other ways to enter this function, the user may feel inconvenient, this is possible for this function in the home Screen creates a shortcut, and the user presses the shortcut directly into the function interface, even if the activity is not the main one.
Launcher shortcuts is a description of how to create a shortcut on home screen for a non-primary activity.
To implement this shortcut, you can do this in the following steps:
1. <intent-filter> add <action android:name= "Android.intent.action.CREATE_SHORTCUT" for activity that requires the creation of a shortcut > identifies this activity to support the addition of shortcuts on home screen. Launcher Shortcuts is an alias for Target Activity-alias,activity-alias, similar to an activity.
2. Add the appropriate user to add a shortcut code, generally in the activity of the OnCreate method for the activity installation shortcuts:
if (Intent.ACTION_CREATE_SHORTCUT.equals (ACTION)) {setupshortcut ();
Finish ();
Return
... private void Setupshortcut () {///I, set up the shortcut intent.
For this example, we simply create a intent that/would bring us directly back to the activity. A more typical implementation would the use of a//data Uri in order to display a more specific result,//or a cus
Tom action in order to//launch a specific operation.
Intent shortcutintent = new Intent (intent.action_main);
Shortcutintent.setclassname (this, This.getclass (). GetName ());
Shortcutintent.putextra (Extra_key, "Apidemos provided this shortcut");
Then, set up the container intent (the response to the caller) Intent Intent = new intent ();
Intent.putextra (Intent.extra_shortcut_intent, shortcutintent); Intent.putextra (Intent.extra_shortcut_name, getString (R. String.shortcut_name));
Parcelable Iconresource = Intent.ShortcutIconResource.fromContext (this, r.drawable.app_sample_code);
Intent.putextra (Intent.extra_shortcut_icon_resource, Iconresource);
Now, return the result to the Launcher Setresult (RESULT_OK, intent); }