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è)頁面
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 UI設(shè)計(jì)與開發(fā)之ViewPager仿微信引導(dǎo)界面以及動(dòng)畫效果
這篇文章主要為大家詳細(xì)介紹了Android UI設(shè)計(jì)與開發(fā)之ViewPager仿微信引導(dǎo)界面以及動(dòng)畫效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
Android WebView 應(yīng)用界面開發(fā)教程
WebView組件本身就是一個(gè)瀏覽器實(shí)現(xiàn),開發(fā)者可以直接在WebView中使用聚合(Polymer)和Material設(shè)計(jì)。接下來通過本文給大家介紹Android WebView 應(yīng)用界面開發(fā)教程,一起看下吧2016-08-08
android中在Activity中響應(yīng)ListView內(nèi)部按鈕的點(diǎn)擊事件的兩種方法
本篇文章主要介紹了android中在Activity中響應(yīng)ListView內(nèi)部按鈕的點(diǎn)擊事件的兩種方法,有需要的可以了解一下。2016-11-11
Android中src和background的區(qū)別詳解
這篇文章主要介紹了Android中src和background的區(qū)別詳解的相關(guān)資料,需要的朋友可以參考下2016-09-09
android 調(diào)用系統(tǒng)的照相機(jī)和圖庫實(shí)例詳解
android手機(jī)有自帶的照相機(jī)和圖庫,我們做的項(xiàng)目中有時(shí)用到上傳圖片到服務(wù)器,今天做了一個(gè)項(xiàng)目用到這個(gè)功能,所以把我的代碼記錄下來和大家分享,有需求的朋友可以參考下2012-12-12
Android自定義控件之水平圓點(diǎn)加載進(jìn)度條
這篇文章主要為大家詳細(xì)介紹了Android自定義控件之水平圓點(diǎn)加載進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06
android開發(fā)之方形圓角listview代碼分享
我寫這篇文章受到了kiritor的專欄發(fā)表的博文Android UI控件之ListView實(shí)現(xiàn)圓角效果的啟發(fā)。2013-06-06

