# Confused About App Icons for Android

**URL:** https://discourse.processing.org/t/confused-about-app-icons-for-android/43105
**Category:** Processing for Android
**Created:** [October 31, 2023, 9:53am UTC](https://discourse.processing.org/t/confused-about-app-icons-for-android/43105 "2023-10-31T09:53:49Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [October 31, 2023, 1:44pm UTC](https://discourse.processing.org/t/confused-about-app-icons-for-android/43105/3 "2023-10-31T13:44:23Z")

</div>

The following source code should create an icon set for Android. Drag and drop the image that you want to use onto the window and a folder should appear on your desktop with the required icons. You will have to change the url for the desktop on your system.

```auto
import java.awt.*;
import java.awt.dnd.*;
import java.util.List;
import javax.swing.TransferHandler;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File;

PFont font;
PImage img;
PImage myimg;
String imgPath = "";
String savePath = "";
String fileName = "";

void setup() {
  size(520, 520);
  surface.setTitle("Icon Maker Android");
  fill(0);
  textSize(30.0);
  textAlign(CENTER, CENTER);
  text("Drag and drop image here", 0, 100, width, 160);
  Canvas canvas = (Canvas) surface.getNative();
  canvas.setDropTarget(new DropTarget(canvas, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetListener() {

    @Override
      public void dragEnter(DropTargetDragEvent dtde) {
    }

    @Override
      public void dragOver(DropTargetDragEvent dtde) {
    }

    @Override
      public void dropActionChanged(DropTargetDragEvent dtde) {
    }
    @Override
      public void dragExit(DropTargetEvent dte) {
    }

    @Override
      public void drop(DropTargetDropEvent evt) {
      // Accept copy drops
      evt.acceptDrop(DnDConstants.ACTION_COPY);
      Transferable transferable = evt.getTransferable();
      // Get the data formats of the dropped item
      DataFlavor[] flavors = transferable.getTransferDataFlavors();
      for (DataFlavor flavor : flavors) {
        try {
          if (flavor.isFlavorJavaFileListType()) {
            // Get all of the dropped files
            List<File> files = new ArrayList<>();
            files = (List)transferable.getTransferData(flavor);
            for (File file : files) {
              imgPath = file.getPath();
              fileName = file.getName();
              // Strip extension if there is one
              if (fileName.indexOf(".") > 0) {
                fileName = fileName.substring(0, fileName.lastIndexOf("."));
              }
  *// ****Change the next line for your system**** //*
              savePath = "/Users/xxxxx/Desktop/AndroidIcons" + "_" + fileName + "/";
              println("imgPath: " + imgPath);
              img = loadImage(imgPath);
              img.resize(0, 512);
              img.save(savePath + "myimg.png"); // used for display
              img.resize(0, 192);
              img.save(savePath + "icon-192.png");
              img.resize(0, 144);
              img.save(savePath + "icon-144.png");
              img.resize(0, 96);
              img.save(savePath + "icon-96.png");
              img.resize(0, 72);
              img.save(savePath + "icon-72.png");
              img.resize(0, 48);
              img.save(savePath + "icon-48.png");
              img.resize(0, 36);
              img.save(savePath + "icon-36.png");
              myimg = loadImage(savePath + "myimg.png");
            }
          }
        }
        catch (Exception e) {
          println(e);
        }
      }
      evt.dropComplete(true); // Inform that the drop is complete
    }
  }
  ));
}

void draw() {
  if (myimg != null) {
    image(myimg, 0, 0, width, height);
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/confused-about-app-icons-for-android/43105)._
