I may have found my problem.

The SurfaceView class implements a function called draw(Canvas).

I unwittingly created my own function draw() with the same signature,
overriding the original. I'm guessing that the SurfaceView probably
calls draw() during unlockCanvasAndPost(). But instead of executing
its original draw() method and doing what it is supposed to do, it
calls my function - simply overwriting the canvas buffer without
affecting the Surface at all... thus the black screen.  I'm still
confused about why it eventually shows. Perhaps some final cleanup
code...

I will test this tonight when I have access to my development computer
and post my findings.



On Apr 15, 8:48 am, Warren <warrenba...@gmail.com> wrote:
> Thanks for the comment ellipsoidmobile.
>
> If I remove the sleep, I still don't see anything until the very end.
> I don't need that sleep in there for the application. I only put it in
> so that, hopefully, I could see what was happening a little better.
>
> Also, I thought that the SurfaceView allowed you to write to the
> screen at your own pace, whatever that may be. So in this case, there
> would be nothing "from the outside" that's causing a screen refresh.
> The screen should stay how I left it until I post a new canvas. Am I
> misunderstanding this?
>
> What really confuses me is why the last call to unlockCanvasAndPost()
> does work.  It seems like if an error prevented the first calls from
> functioning, then it would also prevent the last.
>
> On Apr 15, 3:09 am, "ellipsoidmob...@googlemail.com"
>
> <ellipsoidmob...@googlemail.com> wrote:
> > The problem is your line Thread.currentThread().sleep(1000);//sleep
> > for 1000 ms
>
> > I believe with SurfaceView you have to draw your whole view on 
> > everyscreenrefresh. You just need to loop as fast as possible and the
> > system will throttle the speed in the calls to lockCanvas(). By
> > sleeping for 1 second you are failing to provide a canvas for every
> > refresh so thescreenappears blank.
>
> > What I don't know is whether there is any guidance on how quickly you
> > have to get through your loop, i.e. what the maximum refresh rate is
--~--~---------~--~----~------------~-------~--~----~
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