Which service should I implement if I want it to do each 5 seconds one same work?

42 Views Asked by At

I am new to Android and I am implementing one chat application. I want to create a service which will send one message each 5 seconds to the chat so I can test receiving messages.

I am not sure which service should I implement. I am reading about binded and started, and about Service and IntentService classes. Should I make a separate thread where I could sleep for 5 seconds and run in a loop the same sending message work? I understood that I should in onCreate() method initialize things for sending messages, but I am not sure if I should implement loop in onStartCommand() or somewhere else? I want the service to send always messages so started service should be choosen,right?

Can someone tell me a little bit more about what should I use and why.

Thanks in advance

0

There are 0 best solutions below