[英]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.我有一个应用程序的想法,但没有 Android 开发或网络方面的经验,因此无论这是否可行,我都想获得一些原始反馈。
I want to transfer files,text, etc. between two or more Android phones using WiFi/Mobile network without using a server.我想在不使用服务器的情况下使用 WiFi/移动网络在两部或多部 Android 手机之间传输文件、文本等。 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.
也许一个设备所有者可以将唯一标识该设备的特定字符串(即 IP 地址)发送到它想要与其共享数据的其他设备。
For example, A wants to send some files to B. He tells B that his identifying string is "192.168.1.1:4321".例如,A 想向 B 发送一些文件。他告诉 B 他的识别字符串是“192.168.1.1:4321”。 B now enters this string in the app on his device.
B 现在在他设备上的应用程序中输入这个字符串。 Maybe this way a connection could be made between the two devices.
也许这样可以在两个设备之间建立连接。
There two possible scenarios:有两种可能的情况:
EDIT: Lets just say that there is no WiFi in the region and only one of the devices has a mobile network data plan.编辑:假设该地区没有 WiFi,只有其中一台设备有移动网络数据计划。 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?
那个人能否创建一个 WiFi 热点,以便他可以充当伪服务器,然后其他人可以连接到这个 WiFi 来传输数据,而无需那个唯一的 id 字符串?
For scenario1: yes, you can use wifi p2p (aka wifi direct) to set up a P2P local wifi network to do file transfer.对于场景 1:是的,您可以使用wifi p2p (又名 wifi direct)来设置 P2P 本地 wifi 网络来进行文件传输。 I have seen app developed using this technology to share media files at a demo.
我曾在演示中看到使用此技术开发的应用程序共享媒体文件。 It requires Android 4.0 or later.
它需要 Android 4.0 或更高版本。
For scenario2: I'm afraid the simplest solution is to have your app talk to a server.对于场景 2:恐怕最简单的解决方案是让您的应用程序与服务器通信。 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.
但是,如果您要构建的这个应用程序只是一个个人爱好项目,您可以尝试安装FTP 服务器并让您的应用程序作为客户端与 FTP 服务器通信。 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.
因为即使在 WiFi 中,数据也会通过路由器......尤其是如果您在不同的网络中。 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...更新:正如 dxm 提到的场景 1 是可能的..但是场景 B 每个用户都需要转发端口......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.