public static void createShortcut(Context activity ,Bitmap map ,String appName ,Strin
public static void createShortcut(Context activity ,Bitmap map ,String appName ,String appUrl ,String iconUrl){
Intent shortcut = new Intent(
"com.Android.launcher.action.INSTALL_SHORTCUT");
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,appName);
shortcut.putExtra("duplicate", false);// 设置是否重复创建
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW) ;
// intent.addCateGory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ;
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) ;
intent.setClass(activity, WEBViewActivity.class);// 设置第一个页面
intent.putExtra("keyWord", appUrl);
intent.putExtra("appName", appName) ;
intent.putExtra("iconUrl", iconUrl) ;
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON, map);
activity.sendBroadcast(shortcut);
}
public static void removeShortcut(Context cxt, String shortcutName, String className) {
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setClassName(cxt, className);
Intent intent = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
cxt.sendBroadcast(intent);
}
您可能感兴趣的文章:Android 创建/验证/删除桌面快捷方式(已测试可用)android 为应用程序创建桌面快捷方式技巧分享解析Android应用启动后自动创建桌面快捷方式的实现方法Android的Launcher启动器中添加快捷方式及小部件实例Android添加(创建)、删除及判断是否存在桌面快捷方式的方法Android中创建快捷方式代码实例Android通过应用程序创建快捷方式的方法Android实现向Launcher添加快捷方式的方法android编程实现为程序创建快捷方式的方法Android应用创建桌面快捷方式代码Android应用创建多个快捷方式Android编程实现向桌面添加快捷方式的方法Android编程实现创建,删除,判断快捷方式的方法
--结束END--
本文标题: Android中创建快捷方式及删除快捷方式实现方法
本文链接: https://www.lsjlt.com/news/26661.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0