0

I have an application with remote services and threads that will be started eventually in the services, and I was wondering: should I implement the lifecycle methods such as onPause(), onResume(), onDestroy(), etc. in the Android Activity?

Thanks in advance!

noloman
  • 11,411
  • 20
  • 82
  • 129

1 Answers1

0

If you need to perform any action in these methods then you should handle else there is no need to handle. In service you need to free all the resources in onDestroy() method.

Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • well, in the Activity I simply call button listeners and then I initiate the services, and in the `onDestroy()` method of the services, I do this `@Override public void onDestroy() { super.onDestroy(); serviceHandler.removeCallbacks(myTask); serviceHandler = null; Log.d(getClass().getSimpleName(), "onDestroy()"); }` – noloman Aug 08 '11 at 12:41
  • it's fine then what else do you want to do ? – Vineet Shukla Aug 08 '11 at 12:43
  • well, I was just wondering if Android took care itself of dealing with onResume(), onDestroy(), onPause() and etc. when the methods are not implemented. – noloman Aug 08 '11 at 12:44
  • Call to these methods go at appropriate time but if there is no user task then nothing happens and it is upto your app need whether it needs to override these methods or not...So use these methods when your app needs it....... – Vineet Shukla Aug 08 '11 at 12:48
  • The user task is clicking buttons to activate the different services (3 in my app) – noloman Aug 08 '11 at 13:22