I am connecting different devices with wifi hotspot AP programatically in my android app, How can i detect the clients being connected and disconnected and to the wifi hotspot AP i turned on programmatically ? Is there any callback event in Android API to give information regarding the connection or disconnection events of individual devices ?
Thanks in advance.
I think you need to use WifiP2pDevice
There you can check for available devices, and also if they are connected or not.
Try looking here at the available methods here
EDIT:
This Android Wifi Hotspot Manager Class have sample code to scan /proc/net/arp and ping each known client to detect livelihood.
You can implement that logic in a loop to emulate a Wifi Client disconnect event from driver.
Related
Is there a way to create an app for ios/android that can be smart enough to connect to (wifi / cellular) AND a bluetooth hotspot at the same time?
successfully managed to connect to the bluetooth hotspot and access data however when the phone is on bluetooth it cannot access the internet through cell or wifi
Needs to be able to connect to a bluetooth devices hotspot and access its local host aswell as be able to connect to the internet through wifi/cell at the same time
Or if there is a way to tell the app that any request to the IP of the bluetooth device will go via bluetooth and all other requests through wifi
the worst idea so far - alternate connection between wifi and bluetooth so that both never work at the same time. Possible app permissions nightmare
ideas welcome
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.
I have 2 devices and both support Wifi Direct. I want to turn on Wifi direct in both devices and connect to other device from 1st device by getting it's MAC address programmatically.
However, I'm able to list down nearby Wifi Direct devices in my application and make a connection using WifiP2PDevice object which Android provides in callback of peers list using WifiP2P APIs, but here my approach is to construct WifiP2PDevice object by using remote device MAC address directly and trying to connect it with no luck.
Can anyone help me in resolving this issue?
To connect to any device via wifi-direct, each device need to discover nearby peers or services before attempting to connect to make sure that wifi-direct is enabled and discoverable.
From my tests, even if you have the correct MAC address, trying to connect will not work unless peers or services discovery is executed and the device that you are looking for is discoverable / visible.
If the device is discoverable, you can create new WifiP2PDevice or reuse what's returning from the peers list and connect to it.
I hope I got your question correctly. If not, I'm happy to help if you explain further.
Goodluck.
I want to create an android application.
Is it possible to send a notification from my phone to other phone which has enabled its WiFi hotspot.
I mean, one phone has enabled its WiFi hotspot and I scanned available WiFi devices and I saw its WiFi hotspot ssid at my available wifi list and I want to send a notification or a message without connect its wifi hotspot point, or using bluetooth or using internet.
Is it possible?
There is also NFC - Near Field Communication. It has nothing to do with Wifi though.
So in theory, yes, I believe you can do what you asked. I think you can react to the presence of the other phones Wifi hotspot, but communicate on NFC instead.
As for sample code, I can't help you. I haven't written anything using NFC.
There is also sms or a phone call
I am just getting started with wifi direct. I know that wifi direct works by discovering devices and services. My question is: if I have my wifi enabled on my smartphone and I am not running an application that uses wifi direct, is my phone still discoverable to a phone that is running wifi direct device discovery?
Thanks!
In order to establish a WiFi Direct connection both phones should be running WiFi Direct discovery. In other words, they will see each other when they are both scanning for WiFi direct connections at the same time. This is because the way WiFi Direct works is that when phones are scanning for WiFi Direct connections, they will negotiate with the other peers for the role of Access Point or Slave device. However, when phone A is connected to phone B via WiFi Direct and phone C is scanning for connections, it will detect the connection of A-B since one of them is acting as an Access point.
I will add some point on #Ziad answer. During scan process, one device who started scanning will broadcast 802.11 WiFi Direct probe request and another device will listen to that probe request and send back the probe response, that how they will discover each other.
Scanning will happen on one channel 1, 6 ,11 on 2.4 GHz.