ELBhiri.CoM
ELBhiri.CoM

Reputation: 5

How to keep an activity running to check network?

How to always keep an activity running on the device?

I'm trying to create a chat app like Whatsapp and I want to keep an activity always running, even if the screen is off or the device owner in an other application to check if there is a new message in order to show a notification to the user.

Just exactly like the chat apps: Whatsapp, Viber, Facebook, Voxer, etc.

Upvotes: 0

Views: 75

Answers (2)

Karan
Karan

Reputation: 2130

You can use a Handler which will keep checking for any new updates in the server, but this is not a good way since network bursts like these would be very costly.

Or you can use an IntentService, which will keep listening to any push messages from the server to your device, something like push notifications, which is probably what you are trying to achieve.

Upvotes: 0

Rajesh
Rajesh

Reputation: 15774

That's precisely what Services are for.

Upvotes: 2

Related Questions