My project is based on surfaceView and up until now I\'ve had all of my rendering in onDraw which I am overriding. All seemed to be OK.
However, I\'ve just updated my S
I have the problem since ever.
I handle it like this:
1) Declare a method like the following.
@SuppressLint("WrongCall")
public void drawTheView() {
theCanvas = null;
try{
theCanvas = getHolder().lockCanvas();
if(theCanvas != null) {
onDraw(theCanvas);
}
} finally {
getHolder().unlockCanvasAndPost(theCanvas);
}
}
2) Now you can modify the onDraw() Method:
@Override
public void onDraw(Canvas canvas) {
//Do some drawing
}
You can call the drawTheView() method from everywhere you want and call the onDraw() method this way without getting the error...
I think this is a practical way.