手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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 MVC中如何在在controller中进行页面跳转(到其他Activity)

android开机自启动原理与实现案例(附源码)

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

解析Android中如何做到Service被关闭后又自动启动的实现方法

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

精品推荐
分类导航