android如何添加桌面圖標(biāo)和卸載程序后自動刪除圖標(biāo)
更新時間:2013年06月07日 16:17:42 作者:
android如何添加桌面圖標(biāo)和卸載程序后自動刪除桌面圖標(biāo),這是一個應(yīng)用的安裝與卸載過程對桌面圖標(biāo)的操作,下面與大家分享下具體是如何實現(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");
需要兩個過濾屬性
復(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");
需要兩個過濾屬性
相關(guān)文章
基于Retrofit2+RxJava2實現(xiàn)Android App自動更新
這篇文章主要為大家詳細(xì)介紹了基于Retrofit2+RxJava2實現(xiàn)Android App自動更新,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-05-05Android編程實現(xiàn)點擊鏈接打開APP功能示例
這篇文章主要介紹了Android編程實現(xiàn)點擊鏈接打開APP功能,結(jié)合實例形式較為詳細(xì)的分析了Android實現(xiàn)點擊鏈接打開APP功能的具體步驟與相關(guān)注意事項,需要的朋友可以參考下2017-01-01android RecyclerView的一些優(yōu)化點介紹
大家好,本篇文章主要講的是android RecyclerView的一些優(yōu)化點介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12Android編程實現(xiàn)分頁加載ListView功能示例
這篇文章主要介紹了Android編程實現(xiàn)分頁加載ListView功能,結(jié)合實例形式分析了listview分頁加載的原理、實現(xiàn)技巧與相關(guān)注意事項,需要的朋友可以參考下2017-02-02Android實現(xiàn)3種側(cè)滑效果(仿qq側(cè)滑、抽屜側(cè)滑、普通側(cè)滑)
這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)多種側(cè)滑效果,包括仿qq側(cè)滑,抽屜側(cè)滑,普通側(cè)滑三種效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04