您的位置:首页 > 移动开发 > Android开发

修改一个android应用程序在桌面的图标

2013-10-23 17:26 405 查看
private static final String ACTION_INSTALL_SHORTCUT = 
"com.android.launcher.action.INSTALL_SHORTCUT"; 

/**  
 * 是否可以有多个快捷方式的副本  
*/ 
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate"; 
   
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 intent2 = new Intent(Intent.ACTION_MAIN); 
intent2.addCategory(Intent.CATEGORY_LAUNCHER); 
   
intent2.setComponent(new ComponentName(this.getPackageName(), 
".Main")); 

shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent2); 
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, 
Intent.ShortcutIconResource.fromContext(this, 
R.drawable.icon)); //可以修改icon的值
sendBroadcast(shortcutIntent);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: