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)文章
基于Retrofit2+RxJava2實(shí)現(xiàn)Android App自動(dòng)更新
這篇文章主要為大家詳細(xì)介紹了基于Retrofit2+RxJava2實(shí)現(xiàn)Android App自動(dòng)更新,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05Android編程實(shí)現(xiàn)點(diǎn)擊鏈接打開APP功能示例
這篇文章主要介紹了Android編程實(shí)現(xiàn)點(diǎn)擊鏈接打開APP功能,結(jié)合實(shí)例形式較為詳細(xì)的分析了Android實(shí)現(xiàn)點(diǎn)擊鏈接打開APP功能的具體步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2017-01-01Android實(shí)現(xiàn)讀取NFC卡的編號(hào)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)讀取NFC卡的編號(hào),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09android RecyclerView的一些優(yōu)化點(diǎn)介紹
大家好,本篇文章主要講的是android RecyclerView的一些優(yōu)化點(diǎn)介紹,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12Android編程實(shí)現(xiàn)分頁(yè)加載ListView功能示例
這篇文章主要介紹了Android編程實(shí)現(xiàn)分頁(yè)加載ListView功能,結(jié)合實(shí)例形式分析了listview分頁(yè)加載的原理、實(shí)現(xiàn)技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下2017-02-02Android實(shí)現(xiàn)3種側(cè)滑效果(仿qq側(cè)滑、抽屜側(cè)滑、普通側(cè)滑)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)多種側(cè)滑效果,包括仿qq側(cè)滑,抽屜側(cè)滑,普通側(cè)滑三種效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04