Geting The Ssid And Ip Address Of Connecting Device(before Connecting Need To Get Permission) To Android Hotspot(wifi-tethering)
I like to get the SSID and IP adress of devices trying to connect my hoptspot. Is there any way that i can check them and give permission.
Solution 1:
yes its possible you should register you broadcast receiver inside of activity like this
BroadcastReceiverreceiver=newBroadcastReceiver() {
@OverridepublicvoidonReceive(Context c, Intent intent) {
@OverridepublicvoidonReceive(Context c, Intent intent) {
List<ScanResult> results = wifiDemo.wifi.getScanResults();
ScanResultbestSignal=null;
finalStringaction= intent.getAction();
if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) {
System.out.println("booladsssssssssssssssssssssssssssssss");
}
for (ScanResult result : results) {
if (bestSignal == null
|| WifiManager.compareSignalLevel(bestSignal.level, result.level) < 0)
bestSignal = result;
}
Stringmessage= String.format("%s networks found. %s is the strongest.",
results.size(), bestSignal.SSID);
Toast.makeText(wifiDemo, message, Toast.LENGTH_LONG).show();
Log.d(TAG, "onReceive() message: " + message);
}
and you should put all this the permission to your manifest files ..
<uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE"></uses-permission><uses-permissionandroid:name="android.permission.CHANGE_WIFI_STATE"></uses-permission><uses-permissionandroid:name="android.permission.UPDATE_DEVICE_STATS"></uses-permission><uses-permissionandroid:name="android.permission.CHANGE_NETWORK_STATE"></uses-permission><uses-permissionandroid:name="android.permission.WAKE_LOCK"></uses-permission>
its perfectly worked for me. if you have ant doubt kindly post you comment .. thank you
Post a Comment for "Geting The Ssid And Ip Address Of Connecting Device(before Connecting Need To Get Permission) To Android Hotspot(wifi-tethering)"