Android 程序的快捷方式
来源:互联网 发布:指针怎么指向二维数组 编辑:程序博客网 时间:2024/06/05 18:07
private void addShortcut(){
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
shortcut.putExtra("duplicate", false); //不允许重复创建
//指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer
//注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序
ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName());
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this,TransparentFlashActivity.class));
//快捷方式的图标
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
sendBroadcast(shortcut);
}
/**
* 删除程序的快捷方式
*/
private void delShortcut(){
Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
//快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
//注意: ComponentName的第二个参数必须是完整的类名(包名+类名),否则无法删除快捷方式
String appClass = this.getPackageName() + "." +this.getLocalClassName();
ComponentName comp = new ComponentName(this.getPackageName(), appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
sendBroadcast(shortcut);
}
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
shortcut.putExtra("duplicate", false); //不允许重复创建
//指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer
//注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序
ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName());
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this,TransparentFlashActivity.class));
//快捷方式的图标
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
sendBroadcast(shortcut);
}
/**
* 删除程序的快捷方式
*/
private void delShortcut(){
Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
//快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
//注意: ComponentName的第二个参数必须是完整的类名(包名+类名),否则无法删除快捷方式
String appClass = this.getPackageName() + "." +this.getLocalClassName();
ComponentName comp = new ComponentName(this.getPackageName(), appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
sendBroadcast(shortcut);
}
0 0
- Android 程序的快捷方式
- [android]为程序创建快捷方式
- Android程序创建桌面快捷方式
- Android程序添加桌面快捷方式
- android程序卸载后无法删除桌面快捷方式的解决办法
- Eclipse在开发android程序时使用的常见快捷方式
- android程序卸载后无法删除桌面快捷方式的解决办法
- Android程序首次运行自动创建桌面快捷方式的方法
- android程序卸载后无法删除桌面快捷方式的解决办法
- android程序卸载后无法删除桌面快捷方式的解决办法
- 如何更改Android 程序的icon快捷方式图标?
- android 点击快捷方式提示未安装程序的解决
- 开发Ios、Android程序快捷方式上显示的提示数字
- android 点击快捷方式提示未安装程序的解决
- android 点击快捷方式提示未安装程序的解决
- Android快捷方式的设定
- android 快捷方式的使用
- Android 快捷方式的创建
- 自动装箱和拆箱引出的享元模式
- Eclipse更改字体大小
- poj 3311 Hie with the Pie (TSP)
- 如何以特定的时间间隔为图片添加动画效果?
- Linux oracle 10g EM、ISQLPLUS 按钮乱码解决
- Android 程序的快捷方式
- PreparedStatement查询注意点(CHAR类型结果找不到)
- [python start]如何让内网其他人访问本机程序
- POJ 3301 Texas Trip
- Python+Visual Studio
- Valid Parentheses
- 为什么中断上下文不可以休眠
- 编辑文章 - 博客频道 - CSDN.NET
- socket编程