Shortcuts for creating apps for Android

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.