不直接添加到桌面中,而是添加到添加快捷方式窗口中

voidsetshortCut() {

Intent addShortcut
=newIntent();
//设置快捷方式的名字
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"快捷方式练习");
//构建快捷方式中专门的图标
Parcelable icon=Intent.ShortcutIconResource.fromContext(
ShortcutTest.
this, R.drawable.icon);
//添加快捷方式图标
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
//构建快捷方式执行的Intent
Intent mailto=newIntent(this, ShortcutTest.class);
//添加快捷方式Intent
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mailto);
//正常
setResult(RESULT_OK, addShortcut);

}

 2010123014595192.png

Last modification:July 9, 2011
稀罕你