Exploration and implementation of wireless data transfer between Android phones

Source: Internet
Author: User

Years ago, I studied how Android can implement the Wireless Data Transfer Function and wrote a demo. I have nothing to do with it recently. I want to sort it out and share it with you. Early research found that Android has the following technologies to achieve wireless data transfer: 1. Bluetooth has been used for a long time and is easy to use. However, the slow speed is hard to solve; 2. NFC, officially supported since API 9, however, various manufacturers have a wait-and-see attitude towards this technology. For example, Samsung does not have the NFC hardware, and NFC is applicable to a small amount of data transmission in the near field. The data volume has not been tested yet, however, NFC's so-called near-field distance requirements are quite harsh, basically need to be pasted to pass; 3, WIFI-P2P, transmission speed, and P2P makes the two devices each other C/S, transmission can be performed in two directions. It is officially supported since API 14. Considering that there is a huge amount of equipment maintenance under API 14, this technology can only be abandoned for the time being.

Weigh on, refer to the current various types of wireless fast transmission software, and finally determine to use the Wifi AP method, self-testing compatibility with API 8 devices, fast transmission speed, but only one-way transmission. The Client connects to the Wifi AP enabled on the Server through Wifi. After the connection is successful, the Client initiates an Http request to the Server through HttpEngine. The Server provides the response service to the Client through a simple HttpServer, the following uses a non-standard flowchart to outline the solution process:

 

Before uploading a project, briefly explain several important classes in the source code:

Client

WifiApClientManager: encapsulates the WifiManager interface for enabling, connecting, and other operations.

HttpEngineLite: the "engine" class that initiates Http requests

WifiApClientRequest: Request abstract class, subclass WifiApClientGetRecvListRequest, and WifiApClientGetFileRequest indicate obtaining the list of files to be uploaded from the Server and getting the specified file requests from the Server respectively. Use HttpEngineLite

NanoHTTPClient: Provides operation interfaces for obtaining the list of files to be uploaded on the Server, obtaining specified files on the Server, and managing WifiApClientRequest using the thread pool.

 

Server

WifiApServerManager: encapsulate the WifiManager interface to enable AP and configure AP.

WifiApServerUtil: defines the IP address of the general gateway for Android AP.

NanoHTTPD: this class is the referenced open source code (A simple, tiny, nicely embeddable HTTP server in Java)

NanoHTTPServer: a subclass of NanoHTTPD. It implements its interface and returns the corresponding HttpResponse.

 

Read the fucking source code:

Http://files.cnblogs.com/zealotrouge/WifiAPDemo.7z

 

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.