Android中創(chuàng)建快捷方式及刪除快捷方式實現(xiàn)方法
更新時間:2015年06月09日 11:21:26 投稿:junjie
這篇文章主要介紹了Android中創(chuàng)建快捷方式及刪除快捷方式實現(xiàn)方法,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下
/** * * 創(chuàng)建快捷方式 * @param map 快捷方式圖標 * @param appName 快捷方式標題 * @param appUrl 快捷方式打開的地址 * @param iconUrl 快捷方式圖標地址 * * */ 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);// 設置是否重復創(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);// 設置第一個頁面 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 絕對路徑如: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)建/驗證/刪除桌面快捷方式(已測試可用)
- android 為應用程序創(chuàng)建桌面快捷方式技巧分享
- 解析Android應用啟動后自動創(chuàng)建桌面快捷方式的實現(xiàn)方法
- Android的Launcher啟動器中添加快捷方式及小部件實例
- Android添加(創(chuàng)建)、刪除及判斷是否存在桌面快捷方式的方法
- Android中創(chuàng)建快捷方式代碼實例
- Android通過應用程序創(chuàng)建快捷方式的方法
- Android實現(xiàn)向Launcher添加快捷方式的方法
- android編程實現(xiàn)為程序創(chuàng)建快捷方式的方法
- Android應用創(chuàng)建桌面快捷方式代碼
- Android應用創(chuàng)建多個快捷方式
- Android編程實現(xiàn)向桌面添加快捷方式的方法
- Android編程實現(xiàn)創(chuàng)建,刪除,判斷快捷方式的方法
相關文章
Android在項目中接入騰訊TBS瀏覽器WebView的教程與注意的地方
今天小編就為大家分享一篇關于Android在項目中接入騰訊TBS瀏覽器WebView的教程與注意的地方,小編覺得內容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-10-10修改Android FloatingActionButton的title的文字顏色及背景顏色實例詳解
這篇文章主要介紹了修改Android FloatingActionButton的title的文字顏色及背景顏色實例詳解的相關資料,需要的朋友可以參考下2017-03-03Android Compose實現(xiàn)伸縮ToolBar的思路詳解
這篇文章主要介紹了Android Compose之伸縮ToolBar的實現(xiàn),本文給大家分享主要實現(xiàn)思路及實現(xiàn)過程,通過實例代碼給大家介紹的非常詳細,需要的朋友可以參考下2021-10-10Android自定義View之漸變色折線圖的實現(xiàn)
折線圖的實現(xiàn)方法在github上有很多開源的程序,但是對于初學者來講,簡單一點的教程可能更容易入門,下面這篇文章主要給大家介紹了關于Android自定義View之漸變色折線圖的相關資料,需要的朋友可以參考下2022-04-04