I've also tried calling setMatrix with a real matrix instance that is
explicitly set to identity, but then I start to get unexpected values
from getMatrix.  I really think that I should be able to both get the
current canvas matrix, and reset it without these kind of problems.

Please, if anyone could shed some light on this, it would be greatly
appreciated.

On Oct 15, 11:23 am, miniondev <erics...@gmail.com> wrote:
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to