Read the source code of your friends in one breath, and read the source code of your friends.

Source: Internet
Author: User
Tags sqlite server

Read the source code of your friends in one breath, and read the source code of your friends.

I have been studying Android for a year, and it's almost time to find a job. But I only do one project. What should I do? I heard from my predecessors that I was looking for other people's source code for research, so I did what I said. I am looking for a friend's source code on the internet this time, and I will explain the Implementation ideas in it, it helps you read a source code faster. For the readers, I have also posted this source code. If you are interested, follow these steps.

 

After the software is installed, we find that the features are divided into four modules: Travel memory, companion games, Friends/followers, and other features. Among them, the number of sub-modules in other functions is the most, so let's start with the most.

 

User Registration: in general, this function is to fill in information on the android end and submit it to the server for storage. So what we need to do is to write the android interface and then click Submit, how can I submit data to the server? This is what Alice does: Android installs user information in the form of xml in a StringBuilder, and then writes data to the server through a very simple HttpURLConnection request, when the server servlet receives the data, it saves the data submitted by the client to the MySQL database of the server. (the source code is not optimized. I think a database connection pool can be added ). After the server processes the data submitted by the client, it writes the response data to the user. The user obtains the data to determine whether the login is successful.

 

 

User Login: this is also very simple. Like registration, it is also an android client that writes an interface, and then the user submits the user information to the server. The server also writes a servlet to process the data, the process is to query the database, check whether there is a user record submitted by the user, and write a response to the user. The user determines whether the login is successful based on the response.

 

 

New Memory: this is also very simple. The plain text is similar to the previous registration and login process. The client writes the interface, submits data to the server, and then processes data on the server, it is so easy to save the data to the database. You can also save the data locally, that is, temporary storage. Click the Save button to save the data to the sqlite server of Android.

 

 

Continue unpublished messages: this is also very simple, because the new memory has been saved to the local Sqlite database, so we directly extract the temporary data from the database, then it is loaded into a bundle, and the intent is used to bring the new memory activity, and then the new memory activity processes the data and fills it into the interface.

 

 

Start a companion tour: I thought this would be a little different. After reading it, I found that it was almost the same as the previous one. When I click the launch button, I sent the data filled in by the user to the server servlet for processing, then, a response is sent to the user. The client uses the StringBuilder to store the Xml format, and the server parses and saves the data to the MySQL database on the server through the Sax parsing.

 

 

The above is the implementation of all sub-functions in the "other functions" module. Next we will talk about the travel memory module.

The implementation steps of the travel memory module are as follows: the first step is to send a message to the server. The message sending format is the same as described above, but only one message is sent for the number of requests, after the server obtains the number of requests, it returns the required number to the client. The client obtains the data returned by the server through inputStream, parses the data, and encapsulates the data into the set, then fill in the ListView and display it to the user.

 

 

The companion tour module is similar to the Travel memory module. The request method and Data Processing Method refer to the Travel memory module. However, this new entry is clicked. Click the entry to go to the details display page, and the data is displayed in the past with intent.

 

 

Friends/followers module:

1) The table structure in the table is not understood because the qualification of the minor student is dull. If you understand the table structure, let me know.

The general steps are as follows:

 

1. when thread t1 is enabled, the user requests the server to obtain the list of friends and contacts in the server database. After obtaining the list of friends, the client parses the list, encapsulate data in the list container (put in the String type list here, I think it can be put in a BeanList), that is, all friends.

 

2. Enable thread t2 to obtain the consumer data. The method is the same as that of thread t1, and the list of all consumers is obtained by requesting the server.

 

3. Enable thread t3 to obtain the data applied by all friends, and then install it in the list of friends applications.

 

4. fill in the obtained data to expandableListView, and use onCreateContextMenu in the middle. Baidu found that the biggest difference between this and onCreateOptionMenu is that the former is for every View, the latter is only for the current activity. As long as a contentMenu is registered for a view, the system will respond to the menu pop-up event when the view is long pressed. The menu and the activity menu are of course separated. In the source code, the corresponding contentMenu is registered for each expandableListView item. When the user is long-pressed, there will be different response events, and onContextItemSelected will be called to process the menu click events. Take rejecting friend requests as an example. When a user chooses to reject a friend request, the response event is to send a request to the DeleteApplyServlet of the server, and then the server deletes this request record. Others are similar.

 

This is a general understanding of the source code. If you need to know more about it, you can take a closer look at the source code.

 

 

  • Android_youyou social system source code. Zip (

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.