Android 为程序添加桌面快捷方式
来源:互联网 发布:vue仿豆瓣app源码下载 编辑:程序博客网 时间:2024/04/30 11:02
经过我们一番辛勤劳动过后,看到自己的程序在设备上面跑的时候,或多或少都有点成功感!但程序安装之后,一般来说,程序图标只显示在程序菜单之中,那在我的桌面上呢?有两种方式可以把程序的图标显示在桌面上:
第一:就是在程序菜单中,长按需要显示在桌面上的程序图标,当背景切换到桌面的时候,松开手指,程序的图标自然会显示在桌面上;
但是作为手机或者平板的使用者,追求的是方便,好用。我们当然需要满足他们的要求啦!接下来,说说在程序源码中添加桌面快捷方式,也是这篇文章的重点:
第二:源码中生成桌面快捷方式
第1步,在AndroidManifest.xml文件中添加相应的权限:
- <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
第2步,在适合的地方添加生成快捷方式代码:
- Intent shortcutIntent = new Intent(
- "com.android.launcher.action.INSTALL_SHORTCUT");
- shortcutIntent.putExtra("duplicate",false);
- shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
- getString(R.string.app_name));
- Parcelable icon = Intent.ShortcutIconResource.fromContext(
- getApplicationContext(),R.drawable.ic_launcher);
- shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,icon);
- Intent intent = new Intent(getApplicationContext(),
- ShortCutActivity.class);
- intent.setAction("android.intent.action.MAIN");
- intent.addCategory("android.intent.category.LAUNCHER");
- shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,intent);
- sendBroadcast(shortcutIntent);
- Android 为程序添加桌面快捷方式
- Android 为程序添加桌面快捷方式
- Android程序添加桌面快捷方式
- 为android应用程序添加桌面快捷方式
- android自动添加程序桌面快捷方式
- android桌面添加快捷方式
- Android添加桌面快捷方式
- android 添加桌面快捷方式
- Android中为你的应用程序添加桌面快捷方式
- Android为你的应用程序添加桌面快捷方式
- Android中为你的应用程序添加桌面快捷方式
- Android中为你的应用程序添加桌面快捷方式
- 为程序创建桌面快捷方式
- Android中程序向桌面和Launcher添加快捷方式
- Android 向桌面添加快捷方式
- android添加删除桌面快捷方式
- 【Android】添加删除桌面快捷方式
- Android 向桌面添加快捷方式
- SOLR 4.4 部署
- java中正则表达式提取字符串中日期实现代码
- 程序启动
- 求阶乘(考虑溢出)
- CodeForces 240E E. Road Repairs 树
- Android 为程序添加桌面快捷方式
- Windows上管理远程Linux VPS/服务器文件工具 - winscp
- 算法导论 4-6
- [笔试] 怪物安全问题
- EZ-USB CY7C68013A固件Slave FIFO初始化
- 【Github教程】史上最全github使用方法:github入门到精通
- Mysql配置文件
- COM编程之IDispatch
- cxf log