手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android如何添加桌面图标和卸载程序后自动删除图标
android如何添加桌面图标和卸载程序后自动删除图标
摘要:1:创建图标如下复制代码代码如下:Intentintent=newIntent();intent.setClass(this,SplashA...

1:创建图标如下

复制代码 代码如下:

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:删除图标如下

复制代码 代码如下:

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");

需要两个过滤属性

【android如何添加桌面图标和卸载程序后自动删除图标】相关文章:

Android中将一个图片切割成多个图片的实现方法

Android设置桌面背景图片的实现方法

Android 加载大图片时内存溢出怎么办

Android单选对话框和多选对话框

android 添加随意拖动的桌面悬浮窗口

分享Android平板电脑上开发应用程序不能全屏显示的问题解决

在AndroidManifest.xml文件中设置Android程序的启动界面方法

Android如何防止apk程序被反编译(尊重劳动成果)

Android界面刷新的方法分享

Android应用程序签名步骤及相关知识介绍

精品推荐
分类导航