Skip to main content

Posts

Showing posts with the label Services

Thread vs Service in Android - ABNHive

The thread is part of your program functionality that can run in parallel with the main application execution process (or thread). It runs withing a process. The process may contain only, and that’s rare one thread and mostly contains multiple threads. Threads share the same resources and memory. Creating new thread need very less work that creating a new process. Use a Thread when The app is required to be visible when the operation occurs. background operation is relatively short running (less than a minute or two) the activity/screen/app is highly coupled with the background operation, the user usually 'waits' for this operation to finish before doing anything else in the app. Using a thread in these cases leads to cleaner, more readable & maintainable code. That being said its possible to use a Service( or IntentService). Use a Service when The app could be invisible when the operation occurs (Features like Foreground service could help with operations b...

Services in Android - ABNHive

A service is a component which runs in the background without direct interaction with the user.  A service extends the base class Service . Services run with a higher priority than inactive or invisible activities and therefore it is less likely that the Android system terminates them for resource management. The only reason Android will stop a Service prematurely is to provide additional resources for a foreground component usually an Activity. When this happens, your Service can be configured to restart automatically. You can start a service if it is not running using Context.startService(), connect (bind) to a running service using Context.bindService(), and communicate with the running service through an interface that the service exposes. Each service class must have a corresponding <service> declaration in the AndroidManifest.xml file for its package. Types of Services Bound Service Service which call indefinitely in between activity. An Android component m...