Android Create shortcuts and delete shortcuts

Source: Internet
Author: User

/** * * Create Shortcut * @param map shortcut icon * @param appName shortcut Title * @param appurl Shortcut Open Address * @param iconUrl shortcut icon Address * * */pub Lic static void CreateShortcut (Context activity, Bitmap Map, String appName, String AppUrl, String iconUrl) {Intent SHORTCU t = new Intent ("Com.android.launcher.action.INSTALL_SHORTCUT"); Shortcut.putextra (Intent.extra_shortcut_name, AppName); Shortcut.putextra ("duplicate", false);//Set whether to repeat intent intent = new intent (); Intent.setaction ( Intent.action_view);//intent.addcategory (Intent.category_launcher); Intent.addflags (Intent.FLAG_ACTIVITY_NEW_ TASK); Intent.addflags (Intent.flag_activity_clear_task); Intent.setclass (ACTIVITY, webviewactivity.class);// Set the first page Intent.putextra ("keyword", appurl); Intent.putextra ("AppName", AppName); Intent.putextra ("IconUrl", ICONURL) ; Shortcut.putextra (Intent.extra_shortcut_intent, Intent); Shortcut.putextra (Intent.extra_shortcut_icon, map); Activity.sendbroadcast (shortcut);} /** * * Delete shortcut * @param shortcutname app name * @param className absolute path such as:Getpackagename () + ". Webviewactivity "* * */public static void Removeshortcut (Context cxt, String shortcutname, String className) {Int        ent shortcutintent = new Intent (Intent.action_view);        Shortcutintent.setclassname (CXT, className);        Intent Intent = new Intent ("Com.android.launcher.action.UNINSTALL_SHORTCUT");        Intent.putextra (Intent.extra_shortcut_intent, shortcutintent);        Intent.putextra (Intent.extra_shortcut_name, shortcutname);    Cxt.sendbroadcast (Intent); }



Android Create shortcuts and delete shortcuts

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.