title: Android: How to detect collision between two circles
body: <p>I have drawn multiple circles of varying sizes and positions to a canvas, but I need to detect collisions between them. </p>
  
  <pre><code>public void run() {         
              while(Run){
                  if(!sHold.getSurface().isValid())
                      continue;
  
                  c[0][cnum].r++;
                  canvas = sHold.lockCanvas();
                  canvas.drawRGB(02, 02, 150);
                  Paint white = new Paint();
                  white.setColor(Color.WHITE);
                  if(c[0][cnum].x != 0 &amp;&amp; c[0][cnum].y != 0)
                      canvas.drawCircle(c[0][cnum].x, c[0][cnum].y, c[0][cnum].r, white);
                  if(cnum!=0)
                      for(int i=0; i&lt;cnum; i++)
                          canvas.drawCircle(c[1][i].x, c[1][i].y, c[1][i].r, white);
                  sHold.unlockCanvasAndPost(canvas);
                  if(((c[0][cnum].x - c[0][cnum].r)&lt;0)||((c[0][cnum].y-c[0][cnum].r)&lt;0)||((c[0][cnum].y+c[0][cnum].r)&gt;height)||((c[0][cnum].x+c[0][cnum].r&gt;width))){
                      c[1][cnum].x = c[0][cnum].x;
                      c[1][cnum].y = c[0][cnum].y;
                      c[1][cnum].r = c[0][cnum].r;
                      broken = true;
                      break;
                  }
              }
          }
  </code></pre>