title: Most power efficient way of implementing an Android notification app
body: <p>I'm developing an Android notification app which gets XML data in an MQTT message to build the notification but also contains data to perform an Intent when the Notification is clicked on.
  I implemented Push messaging over using Polling/Pull messaging as I assumed it would be much more efficient to wait for a message to arrive and do something with it over polling a web server for an update and parsing results which may not have any new data.</p>
  
  <p>However, Android's default power saving scheme turns off wi-fi when the screen is off to save power, which means my connection to the MQTT server drops. When I turn back on the screen, my server connection is re-established and the last message on the MQTT server is delivered.</p>
  
  <p>So now I'm faced with a choice. Implement a wi-fi lock in my service code, or use Alarm manager to have my service periodically wake,check for an MQTT publsh and then exit.</p>
  
  <p>This <a href="http://goltermann.cc/2011/11/android-accessing-wifi-even-in-standby-using-wakelock-wifilock-alarmmanager-and-services/" rel="nofollow">wifi wakelock vs. alarm manager</a> suggests that wifilocks are very power inefficient and I should use alarm manager.
  If that's the case, I loose the "instant deliver" advantage of push notification and I'm effictively polling for data.
  How do apps like Google's cloud messaging/WhatsApp/Viber do instant messaging while allowing the device to sleep and not draining the battery by keeping wi-fi active?</p>