Android Create Shortcut

Source: Internet
Author: User

Problem Description:

You want to add a shortcut to your phone's desktop, and the desktop is a system application, which means we need to have an interface to communicate with the system. Fortunately there is a broadcast in Android, and the Android system has a broadcast receiver that receives the added shortcut broadcast. As a result, the shortcut to our application becomes simple.

Key code:

private void CreateShortcut () {        Intent addintent = new Intent ("Com.android.launcher.action.INSTALL_SHORTCUT");                Gets the icon for the shortcut key        parcelable icon = Intent.ShortcutIconResource.fromContext (this, r.drawable.short_cut_icon);        Intent myintent = new Intent (this, shortcutactivity.class);                The title of the shortcut        Addintent.putextra (intent.extra_shortcut_name, "Shortcut");        Shortcut icon        Addintent.putextra (Intent.extra_shortcut_icon_resource, icon);        Shortcut action        Addintent.putextra (Intent.extra_shortcut_intent, myintent);                Send broadcast        sendbroadcast (addintent);    }

Add Permissions:

<uses-permission android:name= "Com.android.launcher.permission.INSTALL_SHORTCUT"/>

the author's latest development of application connection

Http://zhushou.360.cn/detail/index/soft_id/2419729?recrefer=SE_D_%E6%A3%B1%E9%95%9C

Http://www.wandoujia.com/apps/com.mastershield.personalstat


Android Create Shortcut

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.