To create a shortcut, You need to press the button on the desktop, select export cut, and then select the program to create the shortcut. Follow these steps:
1. First, you must add<Action Android: Name = "android. Intent. Action. create_shortcut"/>
1A. Determine whether to add shortcuts:If (getintent (). getaction (). Equals (intent. action_create_shortcut ))
2. Create an intent object
3. Use this object (intent object in step 1) to create a shortcut name. The first parameter is fixed, and the second parameter is customized:Putextra (intent. extra_shortcut_name, "Send email ");
4. Create a shortcut icon and display it on the desktop. The first parameter is context, and the second parameter is the image resource file:Parcelable icon = intent. javascuticonresource. fromcontext (this, R. drawable. mail_edit );
5. Use the intent object (the intent object in step 1) to add a shortcut icon:Putextra (intent. extra_shortcut_icon_resource, icon );
6. Build the intent that the shortcut executes, that is, the operation that is executed after clicking the shortcut. Here is an example of opening an email:
Intent mailto = new intent (intent. action_sendto, Uri. parse ("mailto: xxx@xxx.com "));
7. Use the intent object (the intent object in step 1) to add shortcutsIntent: putextra (intent. extra_shortcut_intent, mailto );
8. Use the setresult method to return the result. The first parameter can be result_ OK or result_canceled. The second parameter is the intent object in Step 1:Setresult (result_ OK, intent object );