网上找了很久都没找到,哪位朋友给一小段代码,或者给的连接呢?
谢谢

解决方案 »

  1.   

    直接在资源文件res->drawable中把图标换成你想要的就可以了啊
    要是.png格式的
      

  2.   

    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);  
      

  3.   


    private void CreateIcon(boolean enc)
    {
    int icon = enc ? R.drawable.icon_enc : R.drawable.icon_dec;
    String ACTION_INSTALL_SHORTCUT  = "com.android.launcher.action.INSTALL_SHORTCUT"; 
    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 mainIntent = new Intent(Intent.ACTION_MAIN);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    mainIntent.setComponent(new ComponentName(this.getPackageName(), 
    "." + this.getLocalClassName()));

    shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mainIntent);
    shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
    Intent.ShortcutIconResource.fromContext(this, icon));
    sendBroadcast(shortCutIntent); 
    }

    private void DeleteIcon() 
    {
    String ACTION_UNINSTALL_SHORTCUT = 
    "com.android.launcher.action.UNINSTALL_SHORTCUT";

    Intent shortCutIntent = new Intent(ACTION_UNINSTALL_SHORTCUT);
    shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));

    Intent mainIntent = new Intent(Intent.ACTION_MAIN);
    mainIntent.setComponent(new ComponentName(this.getPackageName(), 
    "." + this.getLocalClassName()));
    shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mainIntent);
    sendBroadcast(shortCutIntent);
    }上面的代码,CreateIcon可以在桌面创建快捷方式,但是当再次调用时,会提示快捷方式已经存在。
    而DeleteIcon完全不起作用,无法删除快捷方式。