0

Possible Duplicate:
Android Application object life cycle

I'm confused, If I got the application object a service and activity, everyone is up and the activity finish. Does the Application object is alive? or only the service? who is the strongest in this case?

Community
  • 1
  • 1
Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141
  • The "strongest" is `Application` object. It is always the last object to be destroyed in your application. (But this is "as far as i know" but cannot give a quotation source ;)) – Tomasz Gawel Oct 02 '12 at 12:03
  • for my openion i said application.. – Hardik Joshi Oct 02 '12 at 12:03
  • [Here's](http://stackoverflow.com/a/5900291/645270) the answer. The answer is that the Application object is the "strongest". – keyser Oct 02 '12 at 12:06

2 Answers2

1

As far as I know the application object is the last to be destroyed. As long as there exists any service or activity the application object won't be destroyed. - services and activities are independent (but activity on screen has higher priority than running service, while activity which is stopped but not destroyed has lower priority). Started services run as long as they need to, while bound services run until the last bound activity unbinds from it. Thus service can survive activity or vice versa but none of them would survive application object.

Tomasz Gawel
  • 8,379
  • 4
  • 36
  • 61
0

As AndroidManifest shown, all your services located in <application> node.

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <service android:name="ServiceTest"></service>        
</application>

Application object will not call onTerminate method on device and keep your services running.

Yahor10
  • 2,123
  • 1
  • 13
  • 13