Search code examples
androidnotificationsbackground-processandroid-notifications

Get updates from a server in the background using Pull notification - Android


I want to implement a feature in an android app, which periodically pulls information from a server even when the app is in the background / not running.

It should invoke a web service and check for updates at least 3-4 times in a day, and if available pull and show them in the notification bar. When the user clicks on the notification it should open up the app screen.

Is that feasible using pull notification technology? Are there any constraints? Can you share some tutorials that will help me implement this.

Thanks..


Solution

  • Sudo steps hope these helps you to go ahead.

    1. Create One Service This service will call server and gets the updated if available and generate the Notification.
    2. Set Repeat Alarm using AlarmManger When application launches first time every 8 hours that is 4 times in a day.
    3. Create BroadCastReceiver which will called by alarm manager every 8 hours.
    4. And From BroadcastReceive's onReceive() method start the Service for data sync.

    I pretend that you know AlarmMAnager,Service and BroadcastReceiver.

    The working tutorial is Here

    Thanks