Android Programming and Technical Programming Technical

How to stop a service in android?

Options
1) stofSelf()
2) stopService()
3) android may also kill service forcefull in cases of low memory
4) all of the above

Read Solution (Total 0)

Android Other Question

What is the difference between service and a thread?

Options
1) Service - is a component of android, which runs in the background with out any UI. Service will have default one thread to run in background. Thread - is similar to service, it also runs in the background.
2) Service - is a component of android, which runs in the background with out any UI. By default service will run in Main thread only. Thread - is not android component, but still one can use thread to do some background task. Using thread in place of service is discouraged.
3) Option 2 is right, but one can use Thread in place of Service, no problem will come.
4) Option 1 is right, but it may have UI also some times.
start a service from activity and close activity, what will happen to that service, will it be alive or dead?

Options
1) service will also be killed
2) service will be alive for some time, and will be killed by android garbage collector.
3) service will run for ever, no body can stop it now, and it leaks memory.
4) service will be keep running in the background but it can stop itself when the work given to it is done. Or others also can kill that service using stopService(), or android also can kill the service forcefully in case of low memory scenarios.