Android创建桌面快捷方式
来源:互联网 发布:哪个电视直播软件最好 编辑:程序博客网 时间:2024/06/06 05:54
Android创建桌面快捷方式
效果图
添加权限
<!-- 添加创建快捷方式的权限 --><uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
配置快捷启动的Activity
在清单文件下,将要设置快捷启动的Activity添加intent-filter
属性
AndroidManifest.xml
<activity android:name=".Main2Activity"> <intent-filter> <action android:name="android.intent.action.home" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter></activity>
创建快捷方式
/** * 创建快捷图标 * * @param view view */public void createShortcutIcon(View view) { Toast.makeText(this, "创建快捷图标", Toast.LENGTH_SHORT).show(); String title = "第二页"; Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); Intent intent = new Intent(this, Main2Activity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // 添加Intent Intent createShortcutIconIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // 标题 createShortcutIconIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); // 图标 createShortcutIconIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); // Intent createShortcutIconIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // 发送广播创建图标 sendBroadcast(createShortcutIconIntent);}
1 0
- android 创建桌面快捷方式
- Android 创建桌面快捷方式
- android创建桌面快捷方式
- Android 创建桌面快捷方式
- android 创建桌面快捷方式
- Android 创建桌面快捷方式
- Android创建桌面快捷方式
- android 创建桌面快捷方式
- Android 创建桌面快捷方式
- Android 创建桌面快捷方式
- Android 创建桌面快捷方式
- Android:桌面创建快捷方式
- Android创建桌面快捷方式
- android 创建桌面快捷方式
- Android创建桌面快捷方式
- android 创建桌面快捷方式
- Android创建桌面快捷方式
- Android创建桌面快捷方式
- LintCode 143. Sort Colors II
- ActivityCompat使用
- MongoDB 基础
- PHP输出json数据时中文不进行unicode编码的几种方法总结
- android studio 工具使用的常见问题
- Android创建桌面快捷方式
- springMVC上传
- Python学习-机器学习实战-ch07 AdaBoost
- 解决Eclipse建立Maven项目后无法建立src/main/java资源文件夹的办法
- java中的并发工具类
- Spark中组件Mllib的学习32之朴素贝叶斯分类器(伯努利朴素贝叶斯)*
- Linux系统调用--- mount/umount函数详解
- nodejs 安装与配置
- 关于java web 服务器启动报web.xml中的类找不到的问题。