title: Android: How to draw an array of points to a canvas
body: <p>I am reading in an array of points from another activity and creating a path from the points. I have a custom view called "DrawCanvas" that extends View. Currently the code is projecting a blank white canvas. Could someone help me understand why the canvas is not drawing the path?</p>
  
  <p>PreviewActivity.java</p>
  
  <pre><code>public class Preview extends Activity{
  
  Canvas newCanvas = new Canvas();
  MyPointsList object;
  
  protected void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
  
      getIntentData();
      Path path = new Path();
      if(object.getArrayList().get(0) != null){
          for(int i = 0; i &lt; object.getArrayList().size(); i++){
              path.moveTo(object.getMyPoint(i).getX(), object.getMyPoint(i).getY());  
              path.lineTo(object.getMyPoint(i).getX(), object.getMyPoint(i).getY());
          }
      }
  
      FrameLayout canvas1  = new FrameLayout(this);
  
      DrawCanvas view;
      view = new DrawCanvas(Preview.this);
      view.onDraw(newCanvas, path);
      canvas1.addView(view);
  
      setContentView(canvas1);
  }   
  
  
  public void getIntentData(){
      Intent i = this.getIntent();
      if(i.hasExtra("parcel")){
          Bundle b = getIntent().getExtras();
          object = b.getParcelable("parcel");
  
          if(object != null){
              Log.d("Debug", object.getArrayList().get(5).getX() + " " + object.getArrayList().get(5).getY());
  
          }
          else if(object == null){
              Log.d("Debug", "Object is equal to Null");  
          }
      }       
  }
  </code></pre>
  
  <p>DrawCanvas.java</p>
  
  <pre><code>public class DrawCanvas extends View {
  
  public DrawCanvas(Context context) {
      super(context);
      // TODO Auto-generated constructor stub
  }
  
  public void onDraw(Canvas canvas, Path path){
      super.onDraw(canvas);
      canvas.drawARGB(255,255,255,255);
  
      Paint black = new Paint();
      black.setColor(Color.BLACK);
      black.setStyle(Paint.Style.STROKE);
      black.setStrokeJoin(Paint.Join.ROUND);
      black.setStrokeCap(Paint.Cap.ROUND);
      black.setStrokeWidth(3);
  
      canvas.drawPath(path, black);
  }
  </code></pre>
  
  <p>}</p>