title: Android calculate the area of polygon using canvas drawing(not maps)
body: <p>I use this codes for draw a polygon on a canvas. But I want to calculate the area of polygon. Of course give the measurements of each line. I see a lot of example on maps but ı don't convert/adapt on canvas. Can anyone showing a way or method ? </p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;    
  import android.app.Activity;
  import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.Paint.Style;
  import android.graphics.Point;
  import android.os.Bundle;
  import android.view.MotionEvent;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  
  public class MainActivity extends Activity
  {
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(new DrawingView(MainActivity.this));
      }
  
      class DrawingView extends SurfaceView 
      {
          private SurfaceHolder surfaceHolder;
          private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  
          private List&lt;Point&gt; pointsList = new ArrayList&lt;Point&gt;();
  
          public DrawingView(Context context)
          {
              super(context);
              surfaceHolder = getHolder();
              paint.setColor(Color.BLACK);
              paint.setStyle(Style.FILL);
          }
  
          @Override
          public boolean onTouchEvent(MotionEvent event)
          {
              if (event.getAction() == MotionEvent.ACTION_DOWN)
              {
                  if (surfaceHolder.getSurface().isValid()) 
                  {
                      // Add current touch position to the list of points
                      pointsList.add(new Point((int) event.getX(), (int) event.getY()));
  
                      // Get canvas from surface
                      Canvas canvas = surfaceHolder.lockCanvas();
  
                      // Clear screen
                      canvas.drawColor(Color.WHITE);
  
                      // Iterate on the list
                      for (int i = 0; i &lt; pointsList.size(); i++)
                      {
                          Point current = pointsList.get(i);
                          Point first = pointsList.get(0);
  
                          // Draw points
                          canvas.drawCircle(current.x, current.y, 5, paint);                  
  
                          // Draw line with next point (if it exists)
                          if (i + 1 &lt; pointsList.size()) 
                          {
                              Point next = pointsList.get(i + 1);
                              canvas.drawLine(current.x, current.y, next.x, next.y, paint);
                              canvas.drawLine(next.x, next.y, first.x, first.y, paint);
                              c
                          }
  
                      }
  
                      // Release canvas
                      surfaceHolder.unlockCanvasAndPost(canvas);
                  }
              }
              return false;
          }
      }
  }
  </code></pre>