Answer the question
In order to leave comments, you need to log in
How to be or how it works for twitter, etc?
I am writing an application for Android.
In general, it has already been written, there is a certain timer, the function by which once in a while climbs to the server and checks private messages there and displays a notification if there are new messages. Everything works fine, until you switch to another application and the built-in task killer crashes the application when the phone falls asleep. It also happens that the application is not killed, but for no reason, wakes up and continues to work, that is, it all depends on the system and its use at the moment.
I decided somehow to leave this and switch to services or something like that. Here twitter works somehow in the background all the time. Found this tutorial: findevelop.blogspot.com/2012/05/broadcastreceiver-...
In principle, everything is clear. It's not clear, just how to create a notification, if the phone is asleep and I don't have a single Activity, where to send a notification that I need to create it.
Tell me, who solved this problem?
Answer the question
In order to leave comments, you need to log in
It seems to me that the functionality for polling the server is better to be moved to services. And so that android does not kill the service, if it wants, then call setForeground in the serie
Read the guides on how push technologies are systematically implemented, in particular under android - they are implemented differently for apple and windows.
If my wp7 phone connected to the Internet wakes up and croaks both on ICQ and on mail with VKontakte, so does the android lying nearby.
In my opinion, AlarmManager
is suitable for your purposes .
Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question