android - GLES20RecordingCanvas drawBitmap NullPointerException -
i'm trying make ondraw execute @ regular intervals, example every 30ms.
private canvas canvas; private final long updateinterval = 30; private long curdeadline; @override protected void ondraw(canvas canvas) { this.canvas = canvas; long = system.currenttimemillis(); if (now < curdeadline) //too early, need wait { long delay = curdeadline - now; //e.g. start drawing 5ms later handler.postdelayed(rundodraw, delay); } else dodraw(); //execute } private void dodraw() { long = system.currenttimemillis(); curdeadline = now+updateinterval; canvas.drawbitmap(bmp, 0, 0, null); invalidate(); } private runnable rundodraw = new runnable() { public void run() { dodraw(); } };
but throws
java.lang.nullpointerexception @ android.view.gles20recordingcanvas.drawbitmap(gles20recordingcanvas.java:105) @ mygame.dodraw(mygame.java:963) @ mygame.access$1(mygame.java:945) @ mygame$2.run(mygame.java:1007) @ android.os.handler.handlecallback(handler.java:725) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:175) @ android.app.activitythread.main(activitythread.java:5279) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) @ dalvik.system.nativestart.main(native method)
in source code says @ line 105
super.drawbitmap(bitmap, src, dst, paint);
it looks wrong method drawbitmap being called. android bug?
Comments
Post a Comment