/** * * 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