Android Push Service development

Source: Internet
Author: User

Since the company used mobile Client Push service is the Aurora push, to the company caused a hundreds of thousands of service charge, so the company decided to develop its own set of push services, the preliminary technology selection is:

Service side: Netty4

About Netty framework in my blog below I have collated the relevant information, there are some about the Mina because of the time reason has not been sorted out.

To make it easy for you to test yourself, how to use Netty to complete the server-side message push and how the Android client will receive the information displayed in the notification bar, the overall idea is this:

    • The server uses the Netty framework to turn on TCP-based monitoring services.

    • The client initiates a TCP connection (without shutting down, long connection), and implements the heartbeat packet, disconnecting the reconnection mechanism.

    • The server manages long connections (accepts heartbeat packets, handles abnormal connections), and pushes messages.

    • After the client has heard the message, it appears in the notification bar, and when the message is viewed, the client submits the data to the server for statistics.


The server is easy for me to achieve, but because I have not had the Android this piece, have to go to fill some knowledge about Android, I was so analysis:

    • The first thing you need to know is how Android notifies the system notification bar to display something.

    • The next thing to know is the composition of the Android components and how each component communicates.


Ok! After having the basic idea, I began to find information on the Internet.

    • Android is through the Notificationmanager to notify the notification system asynchronously, which is said to be asynchronous may decide that I have a statistical data when there is a data can not be counted (the user has closed the app notification bar), on the internet to find a lot of information, It also says that the Android system does not provide the settings to turn off the notification bar (in fact, I have that feature on my Xiaomi phone). But my first idea is this, since it will provide the system function to manually turn off the notification bar, then the system should broadcast this operation only reasonable ah, unfortunately, there is no such broadcast.

    • The components of Android can be broadly divided into four categories:

      Activity: Usually a separate screen that shows some controls that can also listen and handle user events to respond.

      Service: A long life cycle, no user interface of the program, can be used to develop such as monitoring class programs.

      Content Provider: Contents provider,

      Broadcastreceiver: Broadcast receiver.

      Their communication is generally using intent to communicate, of course, for the sake of security, there are their own way, rewrite the method when you can get the message between the components need to send.


Finally, because the above process itself only spent an afternoon of time to build, Android client code is basically Baidu search, it does not put the source paste out, but they are finally getting started, the overall feeling is quite simple, the operation of the time did not encounter any difficulties, Share your ideas and hope it will be useful for people who are not looking for ways to learn.


This article from "Chen Yanxi" blog, reproduced please contact the author!

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.