首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

设立桌面快捷方式

2012-08-22 
设置桌面快捷方式?如何在程序中设置桌面快捷方式(home screen shortcut):/***创建桌面图标(Home Screen Sh

设置桌面快捷方式

?如何在程序中设置桌面快捷方式(home screen shortcut):

/***创建桌面图标(Home Screen Shortcut)  *   * @param context the context    * @param clz 快捷方式启动的Activity */   public static void makeShortcut(Context context,Class<?> clz) {Intent shortcutIntent = new Intent(context,clz);//      shortcutIntent.setClassName(packageName, name);     shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);     shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);        Intent intent = new Intent();       intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);      intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, context.getResources().getString(R.string.app_name));       intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.icon) );       intent.setAction(Intent.ACTION_CREATE_SHORTCUT);     context.sendBroadcast(intent); }

?????
设置快捷方式的目标Activity 该Activity一般具有如下的设置:
????

<intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter>
1 楼 1927105 2010-08-16   不行啊,我专门写一个工具类也不行啊,,, 2 楼 hyfeng0523 2010-09-08   楼主的方法可行,如果我想要某一个Activity放在桌面快捷方式呢?这个Activity没有MAIN属性与LAUNCHER属性/?如何实现?

热点排行