title: Drawing bitmaps in android
body: <p>I am making an android app just to test for myself. I am trying to draw a bitmap image using canvas, but why isn't it working? It just closes itself a second after startup without any exceptions.</p>
  
  <p>This is the code that i am using so far:</p>
  
  <pre><code>package com.mysoftwaremobileapps.BitmapExample;
  
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.os.Bundle;
  import android.view.MotionEvent;
  
  public class BitmapExampleActivity extends Activity {
  /** Called when the activity is first created. */
  private ArrayList&lt;CustomImageViewActivity&gt; CustomImages;
  Bitmap ImageView1;
  float x;
  float y;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      Canvas c = new Canvas();
      drawImage(c);
  }
  public void doDraw(Canvas canvas)
  {
      for (CustomImageViewActivity p: CustomImages) {
          canvas.drawBitmap(ImageView1, p.getX(), p.getY(), null);
  }
  
  }
  public void drawImage(Canvas canvas)
  {
      ImageView1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
      Paint black;
      black = new Paint();
      black.setStyle(Paint.Style.FILL);
      black.setColor(Color.GRAY);
      canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), black);
      canvas.drawBitmap(ImageView1, null, null);
  
      //Parachuter nr.1
      x = 14;
      y = 28;
  
      CustomImageViewActivity p = new CustomImageViewActivity(x, y);
      CustomImages.add(p);
      Canvas c1 = new Canvas();
      doDraw(c1);
  }
  
  public boolean onTouchEvent(MotionEvent event)
  {
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
          for (CustomImageViewActivity p: CustomImages) {
              p.posX = event.getX();
              p.posY = event.getY();
      }
      }
      return false;
  }
  }
  </code></pre>