Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a Service in my android application?

In my Application I have several Activities and a Java class with a thread. This thread continuously receives and sends messages to the web server. The Application is working fine in testing but I am worried that it may not when being used in actual phones. I am afraid that my background thread which continuously interacts with the Server might be killed by Android, while the app is in background.

Do I really need to make my threaded client class a service ? I want to start it when user signs in and stop it when the user logs off from the system.

If I need to do it please suggest some easy tutorial for it.

like image 852
Amit Avatar asked Jan 14 '23 16:01

Amit


1 Answers

See these links..

http://www.vogella.com/articles/AndroidServices/article.html

Example: Communication between Activity and Service using Messaging

http://androidtrainningcenter.blogspot.in/2012/04/simple-example-of-service-in-android.html

like image 105
Deepzz Avatar answered Jan 21 '23 05:01

Deepzz