android创建桌面快捷方式(启动目标非项目的启动页)
2015-05-11 11:59
567 查看
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);
<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);
相关文章推荐
- Android创建桌面快捷方式并像启动Activity传递参数
- [Android] Android应用启动后自动创建桌面快捷方式
- Android应用启动后自动创建桌面快捷方式
- Android应用启动后自动创建桌面快捷方式
- Android应用启动后自动创建桌面快捷方式
- Android应用启动后自动创建桌面快捷方式
- Android应用启动后自动创建桌面快捷方式
- 解析Android应用启动后自动创建桌面快捷方式的实现方法
- Android创建桌面快捷方式并像启动Activity传递参数
- Android应用启动后自动创建桌面快捷方式
- Android应用启动后自动创建桌面快捷方式
- Android开发:应用启动后自动创建桌面快捷方式(三星机常见)
- Android应用启动后自动创建桌面快捷方式
- Android笔记:Android应用启动后自动创建桌面快捷方式
- Android创建桌面快捷方式
- Android创建桌面快捷方式
- Android编程创建桌面快捷方式的常用方法小结【2种方法】
- Android创建桌面快捷方式几种方法
- Android创建桌面快捷方式所遇到的问题与解决方案
- 关于如何在启动时创建桌面快捷方式