您的位置:首页 > 编程语言

安卓创建快捷图标的代码

2015-07-09 13:39 246 查看
<span style="font-size:24px;">//发送广播的意图, 大吼一声告诉桌面,要创建快捷图标了
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
//快捷方式  要包含3个重要的信息 1,名称 2.图标 3.干什么事情
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "手机小卫士");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
//桌面点击图标对应的意图。
Intent shortcutIntent = new Intent();
shortcutIntent.setAction("android.intent.action.MAIN");
shortcutIntent.addCategory("android.intent.category.LAUNCHER");
//第二个参数是当点击这个快捷图标的时候要启动那个页面的全类名
shortcutIntent.setClassName(getPackageName(), "com.itheima.mobilesafe.SplashActivity");
//		shortcutIntent.setAction("com.itheima.xxxx");
//		shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
sendBroadcast(intent);</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: