how to detect that app connected to local wifi - android

I have two buttons in my app one will be on for local wifi(specially for "ati"), other will be on for if connection is specific server is available like www.google.com
Please help that how can detect the app is connected to local wifi and also how can detect that connection is available to specific server , same behavior as of Reachability in IOS programming

You can use the WifiManager class to get the state of Wi-Fi. I think only way to check whether connection to specific server is available to actually connect.

Related

Android wifi device communication on same router

I am working on an application, where I need to send and receive message on device connected with same router.
Initially i used peer to peer for this. and it is working fine. But my client requirement changed now. he don't want wifi P2P. He want direct communication between device that are connected on same wifi connection or router.
So Is it possible to send and get text between two device connected on same wifi network?
Why not leverage sockets? There is a library called AndroidAsync by koush that will let you create sockets that will listen for data?
It is possible, unless your access point doesn't use a Client Isolation mode, when clients of the same WiFi AP cannot communicate with each other.
Client isolation has been used by the public WiFi APs quite frequently.

How to connect to a saved wifi in android?

I know there are methods to add and connect to a wifi network
How do I connect to a specific Wi-Fi network in Android programmatically?
But what I need is to connect to a network that is already been saved by the user in the device,
Basically I want to connect to the best available network (which user has been connected to earlier) around. I can manage to find the nearby wifi signals and get their strength then I want to connect to the best one.
Also there are couple of inactive threads in SO asking the same question, unfortunately none of them has any answers:
https://stackoverflow.com/questions/24257680/connect-to-a-configured-wifi-network
https://stackoverflow.com/questions/20476702/android-how-do-you-choose-which-previously-saved-wifi-to-connect-to-and-do-it
How to connect to pre-configured Wifi in Android?

How to find out other user connected to the same WIFI network with which you are in android?

Here i want to ask that how can i find out other Mobile phones connected to the same Network(WIFI) with which you are connect, and display it in your Mobile phone. For example there would be an ANDROID app where i will get all the user which is also connected with the same network?
If you wish to create an application that discovers other hosts running it over the same network ...
You could simply send a UDP Broadcast to a specific port. Then all running instances of your app on the network could listen to that port and respond with a message identifying them as a host!
By using CMD...
net view
shutdown/I

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)

How to find a specific device on a wifi network from android?

I'm looking at building a wireless data recording system that will take data measurements and transmit them to a host Android device over a wifi network.
I'm in the early planning stages and need to know is it possible on Android to search a local wifi network for my wireless data system (which will already be connected to network, don't worry about that aspect). Is this possible and how would it be done?
You're looking at using something like multicast DNS to do the discovery. On Java you can use JmDNS (see http://sourceforge.net/projects/jmdns/ for source code: the examples are in the source code download). This would let you have your host system advertise its presence on the local wireless network and then your Android device can search for it and connect to it.

Categories

Resources