1.布局文件中,目标Activity加入以下filter

    <intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

2.通过发送广播的方式调用

      Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.seckill));//设置快捷图标的名字
shortcut.putExtra("duplicate", false);//设置是否重复创建
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClass(getActivity(), ProductListActivity.class);//设置第一个页面
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(getActivity(), R.drawable.wx_friend_non);//设置快捷图标的资源
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
getActivity().sendBroadcast(shortcut);

更多相关文章

  1. Android 布局之LinearLayout
  2. 基本布局之线性布局(LinearLayout)
  3. Android中替换ExpandableListView控件前面的箭头图标
  4. android五种布局特点
  5. 在代码中设置RelativeLayout布局中标签的android:layout_toLeftO
  6. Android帧布局实现霓虹灯的效果
  7. Android点击图标重新启动问题
  8. Android百分比布局(PercentRelativeLayout)嵌套NavigationView自

随机推荐

  1. activity以dialog形式显示
  2. Android(安卓)Studio项目应该提交哪些文
  3. Android(安卓)学习笔记 Thread (一) androi
  4. android菜鸟学习笔记12----Android控件(
  5. Android的第二个应用---电话拨号器
  6. android颜色对应的xml配置值,颜色表
  7. android弹出框2(相当于通知)
  8. android线性布局LinerLayout
  9. Android开发秘籍学习笔记(五)
  10. android animation中的参数interpolator