In the lunar lander example, if I add the following two lines to the
top of the doDraw method, the app crashes immediately on the second
line with a NullPointerException:



Matrix m = canvas.getMatrix();
canvas.setMatrix( null );



Stack trace is:

FATAL EXCEPTION: Thread-8
java.lang.NullPointerException
    at android.graphics.Matrix.preConcat(Matrix.java:233)
    at android.view.Surface$CompatibleCanvas.setMatrix(Surface.java:
259)
    at com.example.android.lunarlander.LunarView
$LunarThread.doDraw(LunarView.java:617)
    at com.example.android.lunarlander.LunarView
$LunarThread.run(LunarView.java:360)




The canvas documentation for setMatrix states that "If the matrix
parameter is null, then the current matrix is reset to identity", so
there's no reason this should crash.

Also, if I do *not* call getMatrix before calling setMatrix(null),
then setMatrix(null) is *successful*.  So somehow it is the
combination of the two calls that causes the problem.

Can anyone help me figure out what's going on here?

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to