to write a back ground functionality in an activity, should I use a thread or service?



to write a back ground functionality in an activity, should I use a thread or service?..

Answer / Simpal Chauhan

For background functionality in an Android activity, you can use either a Thread or a Service. The choice depends on your specific needs:
- A Thread is suitable for short-lived tasks that do not require persistence after the Activity stops (e.g., downloading data quickly). However, it will be killed if the Activity goes into the background.
- A Service provides more flexibility for long-running operations and can run even when the user switches to another app. Use a Service instead of a Thread if you want your task to continue running in the background.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Android OS Interview Questions

Describe the activities of android?

1 Answers  


Explain the steps in creating a bounded service through aidl.

1 Answers  


What are the differences between a domain and a workgroup?

1 Answers  


State the importance of xml- based layouts?

1 Answers  


What are the tools placed in android sdk?

1 Answers  


What is true about localstorage?

1 Answers  


Why ttl (time to live) is required?

1 Answers  


When dealing with multiple resources, which one takes precedence?

1 Answers  


There is a kind of animation that using an xml file to define a sequence of pictures using?

1 Answers  


Is android free for manufacturers?

1 Answers  


How method is implemented in android studio?

1 Answers  


What's android 7.0 called?

1 Answers  


Categories