Android service onCreate is called multiple times without calling onDestroy

I had the same problem when my service used the same process with activities(default). but no more problems when I made my service use another process. I edited my AndroidManifest.xml like below… (added android:process attribute) <service android:name=”kr.co.pkbio.binoo.CacheFileManagerService” android:process=”:kr.co.pkbio.binoo.service”/> <service android:name=”kr.co.pkbio.binoo.ActivityStackManagerService” android:process=”:kr.co.pkbio.binoo.service”/> see http://developer.android.com/guide/topics/manifest/service-element.html for information.

Is ondestroy not always called?

From Android developer documentation: protected void onDestroy () Added in API level 1 Perform any final cleanup before an activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between … Read more

Activity OnDestroy never called?

onDestroy() is called only when system is low on resources(memory, cpu time and so on) and makes a decision to kill your activity/application or when somebody calls finish() on your activity. So, to test your code() you can make a test button, that will call finish() on your activity. Read more here. Also, I believe … Read more

What is Activity.finish() method doing exactly?

When calling finish() on an activity, the method onDestroy() is executed. This method can do things like: Dismiss any dialogs the activity was managing. Close any cursors the activity was managing. Close any open search dialog Also, onDestroy() isn’t a destructor. It doesn’t actually destroy the object. It’s just a method that’s called based on … Read more

Android activity life cycle – what are all these methods for?

See it in Activity Lifecycle (at Android Developers). onCreate(): Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity’s previously frozen state, if there was one. Always … Read more