android 创建快捷方式
来源:互联网 发布:电路考研参考书知乎 编辑:程序博客网 时间:2024/06/04 19:45
通过launcher源码可以看到创建快捷方式是通过
- <receiver android:name="com.android.launcher2.InstallShortcutReceiver" android:permission="com.android.launcher.permission.INSTALL_SHORTCUT">
- <intent-filter>
<action android:name="com.android.launcher.action.INSTALL_SHORTCUT" />
</intent-filter>
</receiver>
生成快捷方式
我们可以在程序启动时直接发送广播创建桌面快捷方式
private void createShortCut(){
Intent intent=new Intent("com.android.launcher.action.INSTALL_SHORTCUT");//action
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));//快捷方式名字
intent.putExtra("duplicate", false); //是否重复创建快捷方式
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);//icon
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext() , BatteryProfile.class)); //启动界面
sendBroadcast(intent);//发送广播
}
我们需要在在mainfest.xml加入以下权限
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
- <receiver android:name="com.android.launcher2.InstallShortcutReceiver" android:permission="com.android.launcher.permission.INSTALL_SHORTCUT">
- <intent-filter>
<action android:name="com.android.launcher.action.INSTALL_SHORTCUT" />
</intent-filter>
</receiver>
生成快捷方式
我们可以在程序启动时直接发送广播创建桌面快捷方式
private void createShortCut(){
Intent intent=new Intent("com.android.launcher.action.INSTALL_SHORTCUT");//action
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));//快捷方式名字
intent.putExtra("duplicate", false); //是否重复创建快捷方式
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);//icon
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext() , BatteryProfile.class)); //启动界面
sendBroadcast(intent);//发送广播
}
我们需要在在mainfest.xml加入以下权限
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
0 0
- Android 创建快捷方式 删除快捷方式
- Android创建快捷方式,Phonegap创建快捷方式
- Android创建快捷方式(shortcut)
- android 代码创建快捷方式
- android创建快捷方式
- android 创建快捷方式
- Android:创建快捷方式
- android 创建桌面快捷方式
- android 创建快捷方式
- android创建任意快捷方式
- Android创建快捷方式
- android 创建快捷方式
- Android--创建快捷方式
- Android 创建桌面快捷方式
- android 创建快捷方式
- Android之创建快捷方式
- android创建桌面快捷方式
- android软件创建快捷方式
- GJB5000A
- AS3学习资料
- Oracle的随机函数
- Mac App Store无法更新和下载软件
- vb.net简单实现透明窗体显示出背景透明的png
- android 创建快捷方式
- delphi7连接excel有的机出现‘无效的类别字符串’解决办法
- 常用的几种数据结构算法(续)
- 将.jar文件编译成.exe文件利用jsmooth
- 3D数学读书笔记——矩阵基础番外篇之线性变换
- php如何以post形式发送xml
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)
- 美派伞兵飞行11小时后空降施救两名中国渔民
- winsows 系统下获取系统时间