手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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 再按一次返回键退出程序实现思路

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

Android如何实现非本地图片的点击态

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

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

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

android ListView内数据的动态添加与删除实例代码

Android开发之SurfaceView显示动画效果

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

精品推荐
分类导航