剧终

我与传说有个约会

导航

创建桌面快捷方式

创建桌面快捷方式用到下面代码
Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.desktop));

配置文件加上:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>

 

Intent intent = new Intent();
intent.setComponent(new ComponentName(this.getPackageName(),".类名"));
增加启动参数:

Bundle bundle = new Bundle();
bundle.putInt("参数key", 参数值);
intent.putExtras(bundle);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
sendBroadcast(shortcutIntent);

 

原文地址:http://www.eoeandroid.com/thread-33391-1-2.html

posted on 2010-12-07 10:51  剧终  阅读(406)  评论(0)    收藏  举报