WiFi Direct Connectivity as a service - android

I am doing an android project. I am using wifi direct to establish communication between two modules. My doubt is that while using the wifi direct to connect to another device a dialog prompts whether to connect to that device. I want to avoid that prompt, It should be connected as it identifies a wifi module. that is by my understanding it should work as a background service. I am a beginner in android programming please help me out in solving this.
Thank You
Midhun

Related

App that will communicate between devices connected on the same local network Wi-Fi

So there's a requirement for an app that will communicate between devices if and only if its connected to the same local network.
E.G: Device A and Device B are connected to Wi-Fi network Z. The app will allow both the Devices to communicate between eachother (send messages/videos)
I've been researching the past couple of days but unable to get clarity with what I've found so far. (I'm confused between NSDManager, WifiP2pManager, etc. as to which one suits my requirement).
I just need confirmation between which concept/methodology to follow. Please help.
From my personal experience, WiFiP2PManager should do what you want. I have used it to connect two devices over the same WiFi network. It also allows your device to view all the other devices on the network and enables you to connect to them. Once you have connected to the device, you can then send messages across the WiFi network. This documentation does a good job of explaining how to use WiFi P2P and how to get started.
It also explains how to view devices on the network, how to connect with them, and how to transfer data. This should suit the requirements that you requested.
You can use NSD, but according to the documentation that is mainly used for giving your app access to services provided from other devices on the local network. It would allow your app to do file sharing with the other device by requesting a service.
After searching it up, I have concluded that WiFi Direct is the same as WiFi P2P. They both use the WiFiP2PManager.Here is a link for information about it.
You can use Network Service Discovery to find and connect to instances of your app. You can then open a socket connection to facilitate communication.
I created and example app on Android and on iOS that does this which I link to and explain in great detail here: http://brendaninnis.ca/connect-nearby-devices-part-2.html

Acquiring host address from manual WiFi Direct connection

I have connected 2 devices via WiFi Direct. This is done manually, and therefore no code has been written for this. In order to send data between the devices, I need the "client" to be able to acquire the host address for the "server".
Is this possible? And if so, any tips on how to go about it?
PS: I know very little of networking, so please excuse any faulty logic.
This is possible for sure. Even you can setup and automate wifi-direct connection via code.
here is nice repo you can refer. https://github.com/mayfourth/WiFi-Direct-File-Transfer

Connect Android devices

I would like to know if there is any way to connect few android phones together? For example, one phone acts as the host and the rest connect to it?
I'm planning to make a game, but I need some connection like this (without Internet connection).
Thank you.
What you're asking for is done by Android Network Service Discovery (NSD). Via the framework you can connect devices without Internet connection (over Wi-Fi/Wi-Fi Direct).
Conceptually it looks as follows:
One device register a service (host);
Other devices discover the service and connect to the host (clients).
Here is a good sample app which may help you start.

How to start a local network connection programmatically via Wi-Fi hotspot on Android?

I want to start a local network connection using the built-in Wi-Fi hotspot on Android devices.
Is there a way to accomplish it?
And how to communicate between two devices?
EDIT:
I want to do it programmatically. Then I can transfer my own data between devices.
I haven't done this before, so my answer is all theoretical.
I think what you need to do is declare one device the server and start its hotspot manually with a known name.
Start / stop built-in Wi-Fi / USB tethering from code? (According to this question, you can't start hotspot programatically).
Once you have the hotspot set up, you start up the server app and wait for incoming connections. The server app can show you the ip address or hostname.
On the clients, you can do a simple check and see if the hotspot name is around and automatically connect to it if you find it. See this link for connecting to a network:
Using WifiManager to connect to a network
As for your second question, how to communicate - you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server.
For reference, I found NanoHttpd, which is a webserver for Android. It uses ServerSocket to listen for incoming connections.
Possible answers:
Before ICS and non rooted devices
There is no way you can connect to a device over wifi. There is no API to do. Bluetooth is your best option or user interaction.
Before ICS and rooted devices
I am not sure if someone hacked the code, but when I tried to do an automatic connection to a wifi spot I noticed:
The api is hidden inside the SDK.
The method that does the connection checks the thread who ask for it. If it's not the os thread, it throws an exception.
Using ICS
With ICS there is a new way to connect devices through wifi called Wi-Fi Direct.
Here is a link with some demos.
If you are going to develop your own application for each and every individual terminals(devices) then i think for you socket programming will do the trick .
Yes , android supports socket programming in the same was as java socket programming .
1st google java socket programming tutorials and then you can using the same knowledge in android .
Also do remember to include the uses internet permission in the manifest , actually thats something which ate my brains for a long time :)
You mean communication between wifi enabled devices without any server like p2p? if so its wifi direct which is supported in ICS check this out http://developer.android.com/reference/android/net/wifi/p2p/package-summary.html
Before ICS there is no standard android API for wifi direct, though Galaxy S2 has wifi direct it uses proprietary API's which 3rd party devs can't use.
i dont know programmically create wify LAN,but you can create wify LAN manually,then you can do java tcp/udp program as said by brianestey
"As for your second question, how to communicate - you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server."
for manual connection follow the steps
take settings/wireless&networks/portable wi-fi hotspot settings from any one of the phone
create new hotspot and turn on wi-fi portable hotspot from there
connect all other device to that hotspot including your pc
you will get ip of each device programmically (includig pc,but i dont know)

Transfer data between two Android using Wifi

I'm trying to develop an Android application which have to be able to transfer data/message between two Android mobiles, as a client server connection using their own Wifi, which having no network or routers nearby. I just tried using Tcp program to do this but it fails, its not connecting, I'm getting ConnectException and connection refused.
[Edited] Is it possible to achieve this using Android Portable Hotspot integrated with application? Is there any tutorial regarding this approach?
Any Ideas, how to do this?
Thanks.
You need to get the two devices networked to each other before you can worry about tcp usage of that network connection.
If one device is willing to perform access-point like functionality as part of a portable hotspot, and you select that as a wirelss network on the other, you may achieve a network connection between the two that can be used for custom traffic. Though there are ways the hotspot could be implemented where that would not work. Also of concern, the "client" device will now be sending all of its network traffic through the hotspot device, including not just foreground apps but anything it decides to do in the background.

Categories

Resources