android - do I have to use a service for a socket in a thread going in background mode -


i have app doing many things , running thread listen port using socket. want able switch app (for ex email) still app continue listen port.

i suppose have use service?

also want listen next incoming request. believe have use bind mechanism re-run through socket.accept() code?

a service continue run if app closed. yes, service way go. can bind service when app opens can communicate between service , app.

also want listen next incoming request. believe have use bind mechanism re-run through socket.accept() code?

you dont necesarily need bind this. service can listen incoming requests itself.

do note service not run on seperate thread if want intensive work, consider spawning different thread inside service. can use intentservice handle threading. can run 1 intentservice if need multiple services, normal service better choice.

also read: https://developer.android.com/guide/components/services.html

and: https://developer.android.com/reference/android/app/service.html

edit: service can stop when app closed. if press home button switch app, app paused , service continue run. can influence life of service. check: android service stops when app closed


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -