添加桌面快捷方式
2011-03-21 01:54
253 查看
1:java代码:
// 要添加的快捷方式的Intent
Intent addShortcut;
// 判断是否要添加快捷方式
if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) {
addShortcut = new Intent();
// 设置快捷方式的名字
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "发送邮件");
// 构建快捷方式中专门的图标
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.mail_edit);
// 添加快捷方式图标
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
// 构建快捷方式执行的Intent
Intent mailto = new Intent(Intent.ACTION_SENDTO,
Uri.parse("mailto:xxx@xxx.com"));
// 添加快捷方式Intent
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mailto);
// 正常
setResult(RESULT_OK, addShortcut);
} else {
// 取消
setResult(RESULT_CANCELED);
}
// 关闭
finish();
2:在AndroidManifest.xml里的内容为:
<activity android:name=".Activity01" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
</activity>
// 要添加的快捷方式的Intent
Intent addShortcut;
// 判断是否要添加快捷方式
if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) {
addShortcut = new Intent();
// 设置快捷方式的名字
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "发送邮件");
// 构建快捷方式中专门的图标
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.mail_edit);
// 添加快捷方式图标
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
// 构建快捷方式执行的Intent
Intent mailto = new Intent(Intent.ACTION_SENDTO,
Uri.parse("mailto:xxx@xxx.com"));
// 添加快捷方式Intent
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mailto);
// 正常
setResult(RESULT_OK, addShortcut);
} else {
// 取消
setResult(RESULT_CANCELED);
}
// 关闭
finish();
2:在AndroidManifest.xml里的内容为:
<activity android:name=".Activity01" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
</activity>
相关文章推荐
- Android中为你的应用程序添加桌面快捷方式
- Android应用添加(创建)和删除及判断是否存在桌面快捷方式
- WinCE桌面添加应用程序的快捷方式
- 在IE网页右键中添加“创建到桌面快捷方式”
- 老外写的在桌面添加快捷方式(DELPHI XE5 ANDROID)
- ubuntu添加桌面或launcher快捷方式
- Android O添加桌面快捷方式的示例
- Ubuntu16.04 添加启动器和桌面快捷方式
- 桌面添加FTP快捷方式
- Android中为你的应用程序添加桌面快捷方式
- ubuntu12.04 eclipse 添加桌面快捷方式
- 如何创建快捷方式并添加到开始菜单、桌面、任务栏....
- Android 为程序添加桌面快捷方式
- Android - 添加桌面快捷方式
- Android应用添加(创建)和删除及判断是否存在桌面快捷方式
- [Android开发实战]Android添加快捷方式到桌面的两种方式
- 如何在Fedora添加桌面快捷方式、如何添加到应用程序
- Android中为你的应用程序添加桌面快捷方式
- win7添加显示桌面快捷方式到任务栏左下角