Android中創(chuàng)建快捷方式及刪除快捷方式實(shí)現(xiàn)方法
更新時(shí)間:2015年06月09日 11:21:26 投稿:junjie
這篇文章主要介紹了Android中創(chuàng)建快捷方式及刪除快捷方式實(shí)現(xiàn)方法,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下
/** * * 創(chuàng)建快捷方式 * @param map 快捷方式圖標(biāo) * @param appName 快捷方式標(biāo)題 * @param appUrl 快捷方式打開的地址 * @param iconUrl 快捷方式圖標(biāo)地址 * * */ public static void createShortcut(Context activity ,Bitmap map ,String appName ,String appUrl ,String iconUrl){ Intent shortcut = new Intent( "com.android.launcher.action.INSTALL_SHORTCUT"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,appName); shortcut.putExtra("duplicate", false);// 設(shè)置是否重復(fù)創(chuàng)建 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);// 設(shè)置第一個(gè)頁(yè)面 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); } /** * * 刪除快捷方式 * @param shortcutName app名字 * @param className 絕對(duì)路徑如:getPackageName() + ".WebViewActivity" * * */ public static void removeShortcut(Context cxt, String shortcutName, String className) { Intent 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 創(chuàng)建/驗(yàn)證/刪除桌面快捷方式(已測(cè)試可用)
- android 為應(yīng)用程序創(chuàng)建桌面快捷方式技巧分享
- 解析Android應(yīng)用啟動(dòng)后自動(dòng)創(chuàng)建桌面快捷方式的實(shí)現(xiàn)方法
- Android的Launcher啟動(dòng)器中添加快捷方式及小部件實(shí)例
- Android添加(創(chuàng)建)、刪除及判斷是否存在桌面快捷方式的方法
- Android中創(chuàng)建快捷方式代碼實(shí)例
- Android通過應(yīng)用程序創(chuàng)建快捷方式的方法
- Android實(shí)現(xiàn)向Launcher添加快捷方式的方法
- android編程實(shí)現(xiàn)為程序創(chuàng)建快捷方式的方法
- Android應(yīng)用創(chuàng)建桌面快捷方式代碼
- Android應(yīng)用創(chuàng)建多個(gè)快捷方式
- Android編程實(shí)現(xiàn)向桌面添加快捷方式的方法
- Android編程實(shí)現(xiàn)創(chuàng)建,刪除,判斷快捷方式的方法
相關(guān)文章
Android在項(xiàng)目中接入騰訊TBS瀏覽器WebView的教程與注意的地方
今天小編就為大家分享一篇關(guān)于Android在項(xiàng)目中接入騰訊TBS瀏覽器WebView的教程與注意的地方,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2018-10-10Android數(shù)據(jù)持久化之File機(jī)制分析
這篇文章主要介紹了Android數(shù)據(jù)持久化之File機(jī)制,較為詳細(xì)的分析了File機(jī)制的原理及Android使用File實(shí)現(xiàn)數(shù)據(jù)持久化的相關(guān)操作技巧,需要的朋友可以參考下2017-05-05修改Android FloatingActionButton的title的文字顏色及背景顏色實(shí)例詳解
這篇文章主要介紹了修改Android FloatingActionButton的title的文字顏色及背景顏色實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-03-03Android Compose實(shí)現(xiàn)伸縮ToolBar的思路詳解
這篇文章主要介紹了Android Compose之伸縮ToolBar的實(shí)現(xiàn),本文給大家分享主要實(shí)現(xiàn)思路及實(shí)現(xiàn)過程,通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-10-10Android自定義View之漸變色折線圖的實(shí)現(xiàn)
折線圖的實(shí)現(xiàn)方法在github上有很多開源的程序,但是對(duì)于初學(xué)者來講,簡(jiǎn)單一點(diǎn)的教程可能更容易入門,下面這篇文章主要給大家介紹了關(guān)于Android自定義View之漸變色折線圖的相關(guān)資料,需要的朋友可以參考下2022-04-04