手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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开发之SurfaceView显示动画效果

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

Android里实现退出主程序的提示代码

Android对开机自启动的限制

android 加载本地联系人实现方法

android MVC中如何在在controller中进行页面跳转(到其他Activity)

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

Android开发简单的乘法计算器,并添加退出菜单

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

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

精品推荐
分类导航