nullpointerexception - Android Canvas drawcolor throws Null pointer exception -
developing small android game (2.1 till 4.2 support), below code throws java.lang.nullpointerexception exception at
canvas.drawcolor((0xffaaaaaa);
public class maingamepanel extends surfaceview implements surfaceholder.callback { public void render(canvas canvas) { canvas.drawcolor(0xffaaaaaa); droid.draw(canvas); } }
here stack trace
java.lang.nullpointerexception @ com.rdx.play.maingamepanel.render(maingamepanel.java:186) @ com.rdx.play.mainthread.run(mainthread.java:54)
the exception inconsistent, might causing issue?
many thanks.
surfaceholder.lockcanvas() allowed return null (cos thread doesn't have same lifetime surface). bet aren't handling possibility in thread function.
Comments
Post a Comment