Android shortcuts 2-add shortcuts to Launcher

Source: Internet
Author: User

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

Related Article

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.