---
title: "Android创建快捷方式(shortcut)"
author: "fonter"
date: "2010-05-25T12:40:09Z"
tags: []
categories: ["移动开发"]
slug: "android-shortcut"
draft: false
lastmod: "2010-05-25T12:42:47Z"
id: 674859
url: "https://fonter.iteye.com/blog/674859"
---

创建应用程序的快捷方式如下：

 

Action

 

```
private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
```

 

 

```
		Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
		shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
				getString(R.string.app_name));
		shortcutIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false);
		Intent intent = new Intent();
		intent.setComponent(new ComponentName(this.getPackageName(),
				".Splash"));

		shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
		shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
				Intent.ShortcutIconResource.fromContext(this,
						R.drawable.icon));
		sendBroadcast(shortcutIntent);
```

 

Uses permission

 

```
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
```

 

 删除快捷方式试了很久没测试成功过，不知那位同学贡献一下代码？