The "Android" implementation is similar to QQ using a friend's avatar as a shortcut.

Source: Internet
Author: User

Reason: The reason for writing this is that the Internet is mostly to tell you how to use the resources in the drawable to do shortcuts, then the local image can do shortcut it? Must be able, so I looked for the next Android source, found that there is such an introduction
    /**     * Activity action:creates a shortcut.     * <p>Input:Nothing.</p>     * <p>output:an Intent representing the shortcut. The intent must contain three     * Extras:shortcut_intent (value:intent), Shortcut_name (value:string),     * and SHOR Tcut_icon (Value:bitmap) or Shortcut_icon_resource     * (value:shortcuticonresource) .</p>     *     * @see # Extra_shortcut_intent     * @see #EXTRA_SHORTCUT_NAME     * @see #EXTRA_SHORTCUT_ICON     * @see #EXTRA_SHORTCUT_ Icon_resource     * @see Android.content.Intent.ShortcutIconResource * *     

It's not hard to see that there are two ways to create a shortcut icon, but most of the first. So let's try the second kind. Solution: Since all read the introduction of the source code, Nature will know how to do it.
public void Createshotcast (context context, class<?> Clazz) {Intent shortcut = new Intent (intent.action_create_ SHORTCUT); Intent shortcutintent = new Intent (intent.action_main); Shortcutintent.setclass (context, clazz); Shortcut.putextra (Intent.extra_shortcut_intent, shortcutintent); Shortcut.putextra (Intent.EXTRA_SHORTCUT_NAME, " Test "),//Intent.extra_shortcut_icon is the Bitmap object Shortcut.putextra (Intent.extra_shortcut_icon, Bitmapfactory.decodefile ("path")); context.sendbroadcast (shortcut);}


The "Android" implementation is similar to QQ using a friend's avatar as a 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.