I have now spent 2 days trying to get this going. I am however completely bamboozled. Individually I have successfully got all the tasks working but I have NO idea how to go about the next part.
Please someone create the steps and simplify the tasks only. I don’t need the code (trying to save you time). I need to know HOW this can be achieved.
-
Every 5/10/15/20/30/60 minutes (according to user preference in app), updates will be checked online receiving a number (number of updates since last check).
-
Even when the app is terminated, I am hoping this can run as a service so updates are still checked (if that’s how it works)
-
Since looking into handler/timer/service/alarmmanager, I am really confused with this now so I also need to know the best way to achieve this.
So, could someone put it thus:
- In ‘name’ activity, add the following code: …
- Create ‘such’ file, adding etc etc in the manifest
- In this part of the code, add your online check code
- Put your status bar notify code here
and so on…
I think the problem is I read way too much with peoples issues on SOF and got confused.
Truly appreciated.
You should use the
Handlerfor timing while application is running andAlarmManagerotherwise. For simplicity you could use the latter for both tasks using this API:I found an example in this blog post. An excerpt:
PendingIntentwith it’sgetBroadcast()method.AlarmManager.BroadcastRecieverand register it inAndroidManifest.xmlas described in the Developer Guide.onReceivemethod ofBroadcastReceiver.Alternatively you could create an
Activity:getActivitymethod for intent instead and pass your activity class to it.