Android implements the method of adding shortcuts to launcher _android

Source: Internet
Author: User

The example in this article describes how Android implements the method of adding shortcuts to launcher. Share to everyone for your reference. Specifically as follows:

When we click on the launcher of the desktop in the application, a dialog box appears prompting you to select the desktop component to add, as shown in the following illustration

When you select a shortcut, a dialog box pops up, displaying a list of the icons and names of the applications to which the shortcut is added. When we want to add an activity that adds a shortcut to this list, simply add an action to the android.intent.action.CREATE_ when the activity is registered Shortcut's intentfilter will be all right.

Shortcutaction class:

Package com.ljq.action;
Import Android.os.Bundle;
 * Add shortcuts to launcher * * 
 @author jiqinlin
class Shortcutaction extends activity {
  @Override public
  void OnCreate (Bundle savedinstancestate) {
    super.oncreate (savedinstancestate);
    Setcontentview (R.layout.main);

Manifest file:

<?xml version= "1.0" encoding= "Utf-8"?> <manifest xmlns:android=
"" 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 ">
        <action android:name= "Android.intent.action.MAIN"/>
          android:name= "Android.intent.category.LAUNCHER"/>
          android:name= " Android.intent.action.CREATE_SHORTCUT "/>
  </ application>
  <uses-sdk android:minsdkversion= "7"/>

Run Result:

I hope this article will help you with your Android program.

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: 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.