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

<pre>
Matrix m = canvas.getMatrix();
canvas.setMatrix( null );
</pre>

Stack trace is:
<pre>
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)
</pre>

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 it would seem that it is the
combination of the two calls that are causing a problem.

Whats going on here?

-- 
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