Android中創(chuàng)建快捷方式及刪除快捷方式實現方法
更新時間:2015年06月09日 11:21:26 投稿:junjie
這篇文章主要介紹了Android中創(chuàng)建快捷方式及刪除快捷方式實現方法,本文直接給出實現代碼,需要的朋友可以參考下
/**
*
* 創(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)建桌面快捷方式的實現方法
- Android的Launcher啟動器中添加快捷方式及小部件實例
- Android添加(創(chuàng)建)、刪除及判斷是否存在桌面快捷方式的方法
- Android中創(chuàng)建快捷方式代碼實例
- Android通過應用程序創(chuàng)建快捷方式的方法
- Android實現向Launcher添加快捷方式的方法
- android編程實現為程序創(chuàng)建快捷方式的方法
- Android應用創(chuàng)建桌面快捷方式代碼
- Android應用創(chuàng)建多個快捷方式
- Android編程實現向桌面添加快捷方式的方法
- Android編程實現創(chuàng)建,刪除,判斷快捷方式的方法
相關文章
Android UI設計與開發(fā)之ViewPager仿微信引導界面以及動畫效果
這篇文章主要為大家詳細介紹了Android UI設計與開發(fā)之ViewPager仿微信引導界面以及動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-08-08
android中在Activity中響應ListView內部按鈕的點擊事件的兩種方法
本篇文章主要介紹了android中在Activity中響應ListView內部按鈕的點擊事件的兩種方法,有需要的可以了解一下。2016-11-11
Android中src和background的區(qū)別詳解
這篇文章主要介紹了Android中src和background的區(qū)別詳解的相關資料,需要的朋友可以參考下2016-09-09
android開發(fā)之方形圓角listview代碼分享
我寫這篇文章受到了kiritor的專欄發(fā)表的博文Android UI控件之ListView實現圓角效果的啟發(fā)。2013-06-06

