android如何添加桌面圖標(biāo)和卸載程序后自動(dòng)刪除圖標(biāo)
更新時(shí)間:2013年06月07日 16:17:42 作者:
android如何添加桌面圖標(biāo)和卸載程序后自動(dòng)刪除桌面圖標(biāo),這是一個(gè)應(yīng)用的安裝與卸載過(guò)程對(duì)桌面圖標(biāo)的操作,下面與大家分享下具體是如何實(shí)現(xiàn)的,感興趣的朋友可以參考下哈
1:創(chuàng)建圖標(biāo)如下
Intent intent = new Intent();
intent.setClass(this, SplashActivity.class);
Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
addShortcut.putExtra("duplicate", 0);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
2:刪除圖標(biāo)如下
Intent intent = new Intent();
intent.setClass(this, SplashActivity.class);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
addShortcut.putExtra("duplicate", 0);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
需要兩個(gè)過(guò)濾屬性
復(fù)制代碼 代碼如下:
Intent intent = new Intent();
intent.setClass(this, SplashActivity.class);
Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
addShortcut.putExtra("duplicate", 0);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
2:刪除圖標(biāo)如下
復(fù)制代碼 代碼如下:
Intent intent = new Intent();
intent.setClass(this, SplashActivity.class);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
addShortcut.putExtra("duplicate", 0);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
需要兩個(gè)過(guò)濾屬性
相關(guān)文章
詳解android特性之CoordinatorLayout用法探析實(shí)例
本篇文章主要介紹了android特性之CoordinatorLayout用法探析實(shí)例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-02-02
Android DigitalClock組件用法實(shí)例
這篇文章主要介紹了Android DigitalClock組件用法,結(jié)合實(shí)例形式分析了DigitalClock組件的布局調(diào)用技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2016-01-01
Android使用SAX解析XML格式數(shù)據(jù)的操作步驟
SAX是一種基于事件驅(qū)動(dòng)的 XML 解析方式,適用于處理大規(guī)模 XML 文檔,本文給大家介紹了Android使用SAX解析XML格式數(shù)據(jù)的操作步驟,并通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-04-04
RecyclerView實(shí)現(xiàn)查看更多及收起
這篇文章主要為大家詳細(xì)介紹了RecyclerView實(shí)現(xiàn)查看更多及收起,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01
Flutter實(shí)現(xiàn)簡(jiǎn)單的下載按鈕動(dòng)畫(huà)
我們?cè)赼pp的開(kāi)發(fā)過(guò)程中經(jīng)常會(huì)用到一些表示進(jìn)度類的動(dòng)畫(huà)效果,比如一個(gè)下載按鈕,那么在flutter中一個(gè)下載按鈕的動(dòng)畫(huà)應(yīng)該如何制作呢,一起來(lái)看看吧2023-05-05
實(shí)現(xiàn)Android studio設(shè)置自動(dòng)導(dǎo)包及自動(dòng)導(dǎo)包快捷鍵
這篇文章主要介紹了實(shí)現(xiàn)Android studio設(shè)置自動(dòng)導(dǎo)包及自動(dòng)導(dǎo)包快捷鍵的相關(guān)資料,需要的朋友可以參考下2017-05-05
Android 自定義可拖拽View界面渲染刷新后不會(huì)自動(dòng)回到起始位置
這篇文章主要介紹了Android 自定義可拖拽View界面渲染刷新后不會(huì)自動(dòng)回到起始位置的實(shí)現(xiàn)代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02
Flutter開(kāi)發(fā)之Widget自定義總結(jié)
這篇文章主要給大家介紹了關(guān)于Flutter開(kāi)發(fā)中Widget自定義的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04

