Xml Code
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. LAUNCHER"/>
</Intent-filter>
In your project list, the following code indicates that the activity is the activity started by the application. The system automatically creates a shortcut. When you use some applications, it sometimes allows you to create shortcuts such as the UC browser. How does this happen? In fact, it is also very simple. Only:
Java code
/**
* What do you want to do with the two lines of code?
*/
Uri uri = Uri. parse ("tel: 0800000123 ");
Intent myIntent = new Intent (Intent. ACTION_DIAL, uri );
Intent shortcut = new Intent ("com. android. launcher. action. INSTALL_SHORTCUT ");
Parcelable icon = Intent. Specify cuticonresource.
FromContext (this, R. drawable. beach); // gets the shortcut key icon
Shortcut cut. putExtra (Intent. EXTRA_SHORTCUT_ICON_RESOURCE, icon); // shortcut icon
// Shortcut. putExtra (Intent. EXTRA_SHORTCUT_ICON, R. drawable. beach); // you can replace the above two lines of code.
Shortcut. putExtra (Intent. EXTRA_SHORTCUT_NAME, "shortcut"); // the title of the shortcut
Shortcut cut. putExtra (Intent. EXTRA_SHORTCUT_INTENT, myIntent); // shortcut action
SendBroadcast (shortcut cut); // you can also tell the system that you have created a shortcut
If you want to add an entry in the create shortcuts bar, for example
You only need to add the following content to the configuration file: (you need to create an activity, NoneShortcut)
Xml Code
<Activity android: name = ". NoneShortcut" android: icon = "@ drawable/photo6" android: label = "Haha">
<Intent-filter>
<Action android: name = "android. intent. action. CREATE_SHORTCUT"/>
</Intent-filter>
</Activity>
This article is from sunney2012"