Android Programming and Technical Programming Technical

Is it possible to have a service with multiple threads in it? How to achieve this?

Options
1) you can't have more than one thread in a service.
2) you can create multiple threads in a service
3) option 2 is possible by creating thread in onCreate()
4) option 2 is possible by creating thread in onStartCommand() of your service class.

Read Solution (Total 0)

Android Other Question

How to update UI from a service that has threads?
Options
1) Create a thread in the Service class and directly access UI components of your activity
2) Since updating UI from other thread directly is not possible, communicate with Main UI thread for the UI updates
3) Use Intent Service
4) Either use option 1 or option 2
How to pass data from activity to service?
Options
1) pass data in intent-putextras, and using setResult()
2) pass data in intent-putextras, and say startService() with that intent
3) store it in common database and access it through both activity and service.
4) can be done using both the ways 2 and 3 options.