Just my 2 stotinki -- I see more and more developers using this WRONG resource acquisition pattern with try...finally:
try { acquireResource(); } finally { releaseResource(); } This is plain wrong. The correct way to obtain a resource and release it is to acquire it BEFORE the try block, and release it in the finally block: acquireResource(); try { // do whatever with the resource } finally { releaseResource(); } if acquireResource could throw an error, the correct way to handle it is in an outer try block: try { acquireResource(); try { // do whatever with the resource } finally { releaseResource(); } } catch (WhateverException e) { } as opposed to this anti-pattern (again widely used): Resource r = null; try { r = acquireResource(); // do whatever with the resource } finally { if (r != null) { releaseResource(); } } Cheers On Fri, Apr 10, 2009 at 8:00 PM, mcmc <manni...@gmail.com> wrote: > > thank you sooo much, everyone! > i've been meaning for someone to tell me that since a very long time > ago, but no one did, so i was stuck! > > :) > > On Apr 9, 3:30 pm, Dianne Hackborn <hack...@android.com> wrote: >> If you want to use the standard 2d APIs, don't use OpenGL. >> >> >> >> On Thu, Apr 9, 2009 at 1:45 PM, mcmc <manni...@gmail.com> wrote: >> >> > wow thanks so much for your help. I think you're right! :D >> >> > however, now I run into another problem. Do you know how to convert >> > openGL to simply using the standard android/java 2D APIs? >> >> > On Apr 9, 2:31 am, "ellipsoidmob...@googlemail.com" >> > <ellipsoidmob...@googlemail.com> wrote: >> > > I hadn't realised you are doing openGL stuff. I've used surfaceview/ >> > > holder in the same was as the lunarlander, but I haven't used openGL >> > > so I don't know how that works. >> >> > > But, at a glance, it looks like you've got a mix of two different >> > > approaches here - maybe the lockcanvas/unlockcanvasandpost approach is >> > > not appropriate when using openGL as the openGL code is controlling >> > > and locking the surface? >> >> -- >> Dianne Hackborn >> Android framework engineer >> hack...@android.com >> >> Note: please don't send private questions to me, as I don't have time to >> provide private support, and so won't reply to such e-mails. All such >> questions should be posted on public forums, where I and others can see and >> answer them. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---