手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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如何添加一个apk使模拟器和真机都编译进去

android 退出程序解决内存释放的问题

android开启图案解锁时,取消滑动解锁

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

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

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

精品推荐
分类导航