Callback On Device Connecting To Wifi Hotspot
I am creating WiFi AP programmatically in my application. Do i get any broadcast when new devices connect to my AP. I know we can get the list of the connected devices from the /p
Solution 1:
If you don't need to use the AP to connect to the internet but just to communicate in a LAN, you can create a P2P group with WifiP2pManager instance createGroup and listen to WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION with a broadcast receiver.
Like this:
if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)){
NetworkInfonetworkInfo= intent.getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);
if (networkInfo.isConnected()) {
Manager.requestConnectionInfo(mChannel, newWifiP2pManager.ConnectionInfoListener(){
@OverridepublicvoidonConnectionInfoAvailable(final WifiP2pInfo info) {
if (info.isGroupOwner) {
mManager.requestGroupInfo(mChannel, newWifiP2pManager.GroupInfoListener() {
@OverridepublicvoidonGroupInfoAvailable(WifiP2pGroup group) {
//This is the size you want
group.getClientList().size();
}
});
}
}
});
}
}
For more detail look at: http://developer.android.com/guide/topics/connectivity/wifip2p.html
Post a Comment for "Callback On Device Connecting To Wifi Hotspot"