10
votes

Sharing files between two devices using wifi can be done by:

  • using wifi direct
  • creating a hotspot on one device and connecting other device to it
  • what is the basic difference between these two methods
  • I mean in the both the options one device serves as the access point while the other connects to it

  • which among the two devices will serve as the access point in case of wifi direct

  • which of the two options is easier and faster
  • I want to use this feature in my android app

    3
    hey which one did you use in your app? I want connection using wifi hotspot in my app. Do you have any sample code for this? If yes, post it as an answer of this question, I'll accept it: stackoverflow.com/questions/39395532/share-files-over-a-hotspotuser6246341
    hey can you share your code if you have?user6649667

    3 Answers

    6
    votes

    One basic difference in usage is that if you use access point approach, any other access point can not be used same time, meaning that if user had existing connection through some access point, it will be terminated.

    Also if there are apps looking for internet connectivity, they might start pushing data as soon as you make a access point connection to the other device, which might pose some security issues (in case the other device has some sniffers ready for sensitive data etc.)

    With WiFi direct, there are no such things as access points, Basically you find a WiFi direct device, and start connection to it. With first creation of the WiFi Direct Group, there is dialog shows for accepting incoming connections (so its always shown in the party we are making the connection to).

    Then when the connection succeeds, one of then devices are chosen to be Group Owner, and any other devices wanting to join the group, should then make connections to the group owner only.

    With WiFi Direct API, you can also use CreateGroup, to pre-select one device to be group owner, This option would also create a Access point with random password.Thus if you want to go with Accesspoint option, you could use this feature for it easily.

    For the easier/faster questions, I would not have any good answers, I would suppose they probably are around the same.

    0
    votes

    It is a type of WiFi where you can connect to other devices or nodes without the need of Access Point. That means you don't need an infrastructure of things for your network to work. Its more like peer to peer network. Also called ad-hoc network.

    0
    votes

    Communicating through wifi will be multi-hoping. Which basically means the data have to go through another node(s), which in this situation is wifi hotspot's soft router.

    Wifi direct is not multi hoping. Its peer to peer. When you look at the documentation, you will find the term 'group owner'. On first look, it looks like an Access point. But any wifi direct capable device can directly communicate with another wifi direct device in the same group without routing through the group owner. But legacy devices still have to use them, I think.

    Group owner, is one of wifi direct capable device in the group decided within the group using a ranking method.

    So, basically, you need to figure out how to rank these two. Which can be done automatically by taking variables like device battery or manually set it to one.

    If sending files within two android devices is what you want, go for wifi direct. As you can use them even when devices are connected to another external wifi network (Not always true, but theoretically it is possible).