# @SuppressLint("WrongCall")



## Crisma (1. Okt 2013)

Hallo,
ich habe eine Frage, und zwar was bedeutet denn: @SuppressLint("WrongCall")

Ich hatte jetzt folgendes Phänomen, ich habe drei Klassen, und in der Klasse MainThread.java rufe ich in der run() Methode die Methode onDraw() aus der MainGamePanel.java Klasse auf
aber Eclipse zeigt mir einen Fehler:
Suspicious method call; should probably call "draw" rather than "onDraw"

Als Fix wird mir dann halt angeboten, dieses @SuppressLint anzufügen, dann klappt es ja auch.
Aber ich finde nirgends, was das zu bedeuten hat und wieso mir Eclipse verbietet meine Methoden aufzurufen. 

Ich hab das ganze aus einem Tutorial und dort wird aber nirgends ein Problem in den Kommentaren beschrieben. 

Kann mir jemand erklären was das ist und was das tut??

Danke und Grüße,
C.

anbei mal die Klassen

hier Zeile 35

```
package de.****thesystem.thenewboston;

import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.util.Log;
import android.view.SurfaceHolder;

public class MainThread extends Thread {

	private static final String TAG = MainThread.class.getSimpleName();

	private boolean running;

	private SurfaceHolder surfaceHolder;
	private MainGamePanel gamePanel;

	// desired fps
	private final static int MAX_FPS = 50;
	// maximam numbers of frames to be skipped
	private static final int MAX_FRAME_SKIPS = 5;
	// the frame periode
	private final static int FRAME_PERIOD = 1000 / MAX_FPS;

	public MainThread(SurfaceHolder surfaceHolder, MainGamePanel gamePanel) {
		super();
		this.surfaceHolder = surfaceHolder;
		this.gamePanel = gamePanel;

	}

	public void setRunning(boolean running) {
		this.running = running;
	}

	@SuppressLint("WrongCall")
	@Override
	public void run() {
		Canvas canvas;
		Log.d(TAG, "Starting Game Loop");

		while (running) {
			canvas = null;
			
			try {
				canvas = this.surfaceHolder.lockCanvas();
				synchronized (surfaceHolder) {
					this.gamePanel.onDraw(canvas);
				}
				
			} finally {
				if (canvas != null) {
					surfaceHolder.unlockCanvasAndPost(canvas);
				}
			} // end finally
		
		}

	}
}
```


```
package de.****thesystem.thenewboston;

import android.app.Activity;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MainGamePanel extends SurfaceView implements SurfaceHolder.Callback  {
	
	private static final String TAG = MainGamePanel.class.getSimpleName();
	public MainThread thread;
	private GreenBall greenBall;
	
	

	public MainGamePanel(Context context) {
		super(context);

		getHolder().addCallback(this);
		
		//create greenBall andf Load
		greenBall = new GreenBall(BitmapFactory.decodeResource(getResources(), R.drawable.greenball), 50, 50);
		
		
		thread = new MainThread(getHolder(), this);
		
		setFocusable(true);
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		thread.setRunning(true);
		thread.start();
		
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		boolean retry = true;
		while(retry) {
			try {
				thread.join();
				retry = false;
			} catch (InterruptedException e) {
				// try again shutting down the thread
			}
		}
		
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			// delegating event handling to the droid
			greenBall.handleActionDown((int)event.getX(), (int)event.getY());
			
			// check if in the lower part of the screen we exit
			if (event.getY() > getHeight() - 50) {
				thread.setRunning(false);
				((Activity)getContext()).finish();
			} else {
				Log.d(TAG, "Coords: x=" + event.getX() + ",y=" + event.getY());
			}
		} if (event.getAction() == MotionEvent.ACTION_MOVE) {
			// the gestures
			if (greenBall.isTouched()) {
				// the droid was picked up and is being dragged
				greenBall.setX((int)event.getX());
				greenBall.setY((int)event.getY());
			}
		} if (event.getAction() == MotionEvent.ACTION_UP) {
			// touch was released
			if (greenBall.isTouched()) {
				greenBall.setTouched(false);
			}
		}
		return true;
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		canvas.drawColor(Color.RED);
		greenBall.draw(canvas);
		
	}
}
```

noch die Activity Klasse, falls wichtig (die spinnt aber noch rum)

```
package de.****thesystem.thenewboston;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class DroidzActivity extends Activity {
	
	private static final String TAG = DroidzActivity.class.getSimpleName();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		setContentView(new MainGamePanel(this));
		Log.d(TAG, "view added");
		
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		Log.d(TAG, "destryoing...");
		super.onDestroy();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		Log.d(TAG, "stopping...");
		super.onStop();
	}
	
	

}
```


----------



## VfL_Freak (2. Okt 2013)

Moin,

schon mal danach gegoogled ???:L

https://www.google.de/#q=@SuppressLint

Gruß
Klaus


----------



## Crisma (2. Okt 2013)

ja sicher


----------

