0

i am using camera resource in my activity some time activity does not respond and ask for force close how can we release our resources on force close of activity

Sunil Pandey
  • 7,042
  • 7
  • 35
  • 48
  • you'd better find out why it force closes (*asks* for? is it an Application Not Responding issue?) – bigstones Feb 22 '11 at 11:01
  • ya! i am capturing image using camera in my activity but it is not responding for long and finally ask for force close. after that i could not open any app related to cam – Sunil Pandey Feb 22 '11 at 11:06
  • you should post a question to solve the ANR. if the app just gets killed by the system, i don't know how many chances you have to release resources. see here: http://stackoverflow.com/questions/3855745/handle-force-close – bigstones Feb 22 '11 at 11:15

2 Answers2

0

You can't. Once Android needs to force close your app, it's already past the point where you can execute any code.

However, Android should release your resources for you so you shouldn't need to worry.

RivieraKid
  • 5,923
  • 4
  • 38
  • 47
  • 2
    my camera resource is not getting released – Sunil Pandey Feb 22 '11 at 11:42
  • @bigstones is correct - you need to fix the reason for force close or ANR. It almost sounds like you are blocking the UI thread, which will guarantee an ANR. If it is force closing, then you cannot release your resources. If you are getting ANR, you should be able to avoid that. – RivieraKid Feb 22 '11 at 11:53
0

AFAIK there is a method called onLowMemory() that can be overridden in any class where you can access context parameter. But it is called only when your application is running out of memory and you can perform only those tasks which do not require extra memory.

Prasham
  • 6,646
  • 8
  • 38
  • 55
  • That's absolutely right, though at the point of a force close, it's already far beyond `onLowMemory()`, and `onLowMemory()` is only called if the force close was due to low memory. @Sunil really needs to address the reasons for the force close/ANR first. – RivieraKid Feb 22 '11 at 12:39