Message push chat implementation for Android

Source: Internet
Author: User

One day, I found that Baidu had a cloud push package. I think Baidu's server is still relatively stable. What's more stable than our own server, it took me a few days to write a small chat tool. The right tool should be a trainer. In the future, if an application only needs to push messages to users, it is not necessary to build a server by myself, add the Baidu package to save a lot of trouble. Well, let's take a look at this little tool. Due to the rush of time, bugs and errors are inevitable. I hope my friends can be patient and debug it on their own. Thank you, if I receive the email, it will be processed in time. Thank you again !!!

 

 


Because the amount of code is still relatively large, I will not post code here. Let's briefly talk about the principle. Let's first look at the source code structure:

 



Com. way. activity: Of course, all the activities.


Com. way. adapter: this is all the adapters used, such as ListView.


Com. way. app: I put two classes here. One is Application, which is used as a tool class for saving global variables, and the other is used to replace the class for system Exception Handling. If an error is reported, the system will save the error information to the file and prompt the user to send it to me by email. I hope my friends will send the log to me if they encounter an error. Thank you!


Com. way. baidupush. client: Here is the broadcast receiver who receives messages pushed by Baidu server: PushMessageReceiver. All messages are received here. In addition, I added a network change receiver, perform different operations based on network conditions.


Com. way. baidupush. server: Here is the encapsulation of sent messages. The messages we want to push are sent to the Baidu server through HTTP, mainly the encapsulation of HTTP requests.


Com. way. bean: This is a bean package. I will not talk about it much. The basic knowledge of JAVA is java bean.


Com. way. common. UI: l here are some tool packages, such as Log encapsulation, Toast encapsulation, network judgment, asynchronous message sending task, and Dialog...


Com. way. db: This is a database operation package. User, Message, and recent calls are stored in the database.

Com. way. fragment: place the left menu and right menu fragment of the left and right sliding menu.

Next, all the packages are open-source project views, so I will not explain them much.


 

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.