Android Services:
-
What is an Android Service, and when should you use it?
- A Service is a component that runs in the background to perform long-running operations independently of the UI. Use it for tasks that need to continue running even when your app is not in the foreground.
-
Explain the difference between started and bound services in Android.
- Use startService() to initiate a started service that operates independently. In contrast, bindService() establishes a bound service enabling direct component interactions.
-
What is an IntentService in Android, and how is it used for background tasks?
- An IntentService is a subclass of Service that performs background tasks in response to intents. It manages work in a worker thread automatically and ceases upon task completion.
-
What is a Foreground Service in Android, and why is it important?
- A Foreground Service is a service that has a persistent notification to inform the user about ongoing background tasks. It serves tasks demanding high priority and user awareness.
-
Explain the concept of a Bound Service in Android.
- A Bound Service permits other components (e.g., activities) to bind to it, facilitating interaction by invoking methods or accessing its data.
-
How do you communicate between an Activity and a Service in Android?
- You can facilitate communication between an Activity and a Service by employing bindService() to create a connection, subsequently invoking methods or employing callbacks to exchange data