Reputation: 348
I want to build a data sharing application on android using wi-fi like "SHAREit" but I did not get where I start from.
So if any clear me the technical concept of "SHAREit" it was very much efficient to understand.
Please all resources and links that I could run to test.
Upvotes: 22
Views: 38480
Reputation: 1540
I've made an attempt to write a library called SHAREthem to simulate how SHAREit works. Library facilitates P2P file sharing and transfers between devices using WiFi Hotspot. It also supports app to web sharing if receiver has no app installed. Hope it helps to you understand technicals involved in file sharing using WiFi Hotspot.
Since there are many moving parts to this library, i made a blog with implementation details. Will try to cover a few components here:
HotspotController
HC uses Java Reflection since there are NO APIs available on Android for enabling/disabling Hotspots. Functionalities include:
Controller creates an OPEN Wifi hotspot configuration with an SSID which can intercepted by Receivers to recognize SHAREthem senders including port and sender names.
Restores user Hotspot-Configuration when Share mode is disabled
Provides a list of connected WiFi clients.
SHAREthem Server
A tiny HTTP server extended from NanoHttpd, serves the sender data to receivers using IP address as hostname and works on port assigned by user or system by default.
SHAREthem Service
Android service which manages lifecycle of SHAREthem-server and also handles foreground notification with stop action.
UI (Activities)
Android activities to handle share/receive actions
Receiver - provides UI to list the files available to download. Posts a download request to Android Download Manager to start file downloads.
Sender - displays IP, Port & connected clients info along with file transfer status for each connected client(Receiver).
Upvotes: 13
Reputation: 2223
Use the Android Wi-Fi P2P libaries, and start with the doc on this page. It tells you how use Wi-Fi P2P for service discovery, which takes care of item 1 in your requirements. Basically, you have each device transmit a DNS-SD TXT that can contain user ID info, etc. Devices can see its contents without having to establish a socket, which is what you will later do to accomplish item 2 in your requirements.
Upvotes: 5