您的位置:首页 > 移动开发 > Android开发

android 创建快捷方式

2012-12-12 23:35 260 查看
部分代码:

private void shortCut(){
		
		Intent intent = new Intent();
		intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
		intent.putExtra("duplicate", false);
		intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "hello");//标题
		Intent.ShortcutIconResource sr = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);//自定义图标
		intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, sr);
		intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, this.getClass()));
		this.sendBroadcast(intent);
	}


权限配置:

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: