Android Push principle
Since the recent project involved Android push, I saw something about Android push, and we know that the Android push can come down to 3 kinds of implementations:
1, POLL, pull. The general idea is to send the request to the server regularly, and then let the server return the information itself.
Advantages: Simple to implement.
Disadvantage: Poor real-time. If there are many small connections at timed intervals, there are high pressure requirements on the server. It is said that the electricity ... I don't know if it's true.
2, SMS, MMS mode . It is said to intercept MMS and parse content. This has not been hands-on.
Advantages: Simple to implement. Real-time sex.
Disadvantage: The cost of SMS services. Your!
3, TCP/IP, long-lasting long connection. simply set up a persistent TCP/IP connection with the server, and the server can send you a message.
Advantages: Good real-time performance.
Disadvantage: It is more difficult to achieve. It is said to be more cost-electric ... I haven't tested it.
Poll is simpler, using timer and TimerTask timers, and several HTTP-related classes to achieve basic functionality, and then resolve the server's return information itself.
It is mainly about the implementation of persistent long connection:1, based on IBM's MQTT implementation. 2, based on XMPP implementation
Based on the XMPP implementation there is a ANDROIDPN project, open source. Although I used MQTT in the back item. Because ANDROIDPN is not mature enough, there are some bugs in it, I can not repair it temporarily. Because I've only looked at the source code on the Android side, maybe some bugs need to be modified on the server side. ( the problem that bothers me for a long time is that after the server restarts, the ANDROIDPN handset can not be reset, temporarily put down, wait for the need to chew it again )
Its project source code here can be: http://sourceforge.net/projects/androidpn/went in after the files tag has 3 resources:
Androidpn-server Server-side code
Androidpn-demoapp instance (honestly, nothing)
Androidpn-client phone-side code
Add: I remember importing items may appear: Unable to resolve target ' Google Inc.: Google apis:7 ' error prompts.
WORKAROUND: Project Right button, Properties,resource,text file Encoding,other, select UTF-8
Android,project build Target, select Android1.5
Thank you for reading, I hope to help you, thank you for your support for this site!