Message push mechanism for Android

Source: Internet
Author: User
Tags android push notification

Android provides several common methods to push and receive messages:

1. Round Robin: ApplicationProgramYou should establish connections with the server in stages and check whether new messages arrive. You must implement communication with the server yourself, such as Message Queuing. In addition, you also need to consider the polling frequency. If it is too slow, it may lead to delay of some messages. If it is too fast, it will consume a lot of network bandwidth and battery.

2. persistent connection: this solution can solve the performance problem caused by polling, but it will still consume the cell phone's battery. The push service of apple works well because each mobile phone only maintains a connection with the server. In fact, c2dm works like this. However, this solution also has shortcomings, that is, it is difficult for us to implement a reliable service on the mobile phone. The Android operating system allows you to kill system services with low memory, so your notification service may be killed by the operating system.

In comparison, the 2nd types are the most feasible.Write System services or boot functions for the software; orIf the system resources are low, you can restart the service in the ondestroy () method after the service is shut down to achieve persistent connection.

There are currently some ready-made frameworks, such as androidpn (Android push notification), See http://blog.csdn.net/way_ping_li/article/details/7948269

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.