简体   繁体   中英

Transfer data between 2 android phones without a server?

I have an idea for an app but no experience in Android development or networking for that matter, so would like to have some raw feedback whether this is possible or not.

I want to transfer files,text, etc. between two or more Android phones using WiFi/Mobile network without using a server. Maybe one device owner can send a particular string that uniquely identifies that device ie IP address, to other devices with which it wants to share the data.

For example, A wants to send some files to B. He tells B that his identifying string is "192.168.1.1:4321". B now enters this string in the app on his device. Maybe this way a connection could be made between the two devices.

There two possible scenarios:

  1. Both A and B are nearby each other so that they can have access to the same WiFi network.
  2. A and B are in different geographic locations such that both are using mobile network or in difference WiFi zones.

EDIT: Lets just say that there is no WiFi in the region and only one of the devices has a mobile network data plan. Can that person create a WiFi hotspot so that he can act as a pseudo-server and others can then connect to this WiFi to transfer the data without the need of that unique id string?

For scenario1: yes, you can use wifi p2p (aka wifi direct) to set up a P2P local wifi network to do file transfer. I have seen app developed using this technology to share media files at a demo. It requires Android 4.0 or later.
For scenario2: I'm afraid the simplest solution is to have your app talk to a server. However, if this app you want to build is just a personal hobby project, you can try to install FTP server and have your app talk to FTP server as a client. This way the phone serves both as a server and a client, and it does not need a central server at all. Obviously it is very hard to set up and will not be a very good idea to put on market.

I think in Both way's you would need to do port forwarding. Because even in WiFi the data goes over the router.. And especially if you are in different networks. For public use you can't get away of a server where both clients can connect and then you can send data between them... Otherwise every user of your app would need to forward port... Correct me if I'm wrong but I'm pretty sure...

Update: As dxm mentioned scenario 1 could be possible.. But scenario B every user would need to forward port...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM