---
title: "BY DEFAULT, WHEN A SERVICE DECLARED IN THE ANDROIDMANIFEST, IN WHICH THREAD WILL IT RUN?"  
description: "BY DEFAULT, WHEN A SERVICE DECLARED IN THE ANDROIDMANIFEST, IN WHICH THREAD WILL IT RUN?"  
author: "Shray singh"  
published: 2018-01-23  
canonical: https://answers.mindstick.com/qa/33514/by-default-when-a-service-declared-in-the-androidmanifest-in-which-thread-will-it-run  
category: "technology"  
tags: ["android"]  
reading_time: 1 minute  

---

# BY DEFAULT, WHEN A SERVICE DECLARED IN THE ANDROIDMANIFEST, IN WHICH THREAD WILL IT RUN?

BY [DEFAULT](https://www.mindstick.com/interview/2204/what-are-the-new-enhancements-done-in-default-project-template-of-asp-dot-net-mvc-4), WHEN A [SERVICE](https://www.mindstick.com/articles/85570/affordable-and-reliable-limo-service-in-ny) DECLARED IN THE ANDROIDMANIFEST, IN WHICH THREAD WILL IT RUN?

## Answers

### Answer by Prateek sharma

By Default, a service runs on the **main thread.** So if you want to do some long running task you need to make your service run on the background thread.

There are basically three types of service -

1. Bound
2. Foreground
3. Background

To create a service you need to create a subclass for service or use any existing subclass for the service. It is important to override some of the important callback methods of service class in order to run a service properly. There are some callback methods which need to be implemented such as-

1. onStartCommand
2. onBind
3. onCreate
4. onDestroy

In manifest, you need to declare your service -

<manifest ... >

...

<application ... >

<service android:name=".ExampleService" />

...

</application>

</manifest>


---

Original Source: https://answers.mindstick.com/qa/33514/by-default-when-a-service-declared-in-the-androidmanifest-in-which-thread-will-it-run

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
