onDraw(Canvas canvas) in a thread using android API
<p>why does this not work? it prints the locations as the should but it does not move the image on the screen? i am using an emulator.</p>

<p>i think the image should be moving around but it stays in the same place even though the x and y values are changing. i think the problem may be the canvas i am using when i call onDraw(canvas). what can i do to this canvas to make it work (if the canvas is the problem)?</p>

<p>if this is not enough detail please tell me. code below;</p>

<pre><code>  GameView.java

  package com.example.game;

  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.view.View;

  public class GameView extends View implements Runnable{
Thread gameLoop = new Thread(this);
boolean running = false;
int x = 10;
int y = 10;
Canvas canvas = new Canvas();


private Bitmap bmp;
public GameView(Context context) {
    super(context);
    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
}

  @Override
public void onDraw(Canvas canvas) { 
    canvas.drawColor(Color.BLACK);  
    canvas.drawBitmap(bmp, x, y, null);
    System.out.println(x);
    if(x &lt; 100) {
        x+=10;
    }

    if(x &gt;= 99 &amp;&amp; y &lt; 400) {
        y+=10;
    }

    if(y &gt; 350 &amp;&amp; x &gt;= 99) {
        x = 10;
        y = 10;
    }
  }

public void start() {
    if(!running) {
        running = true;
        gameLoop.start();
    }
}

public void stop() {
    if(running) {
        running = false;
    }
}


  @Override
public void run() {
while(running) {
    try{
    onDraw(canvas);
    Thread.sleep(1000);
    }catch(Exception exc) {System.err.println("error sleep interup");}
}

}

  }



  Main.java

     package com.example.game;

  import android.app.Activity;
  import android.os.Bundle;

  public class Main extends Activity {

GameView gv;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    gv = new GameView(this);
    setContentView(gv);

    gv.start();
}    
</code></pre>

<p>}</p>
