简体   繁体   中英

Android blacklist wifi bssid

I have a problem banning a specific bssid. I can see there is a class called WifiNative that was in api 19 but not able to access it: https://android.googlesource.com/platform/frameworks/base/+/kitkat-release/wifi/java/android/net/wifi/WifiNative.java

Is there any other way anyone knows of to do this? Maybe via JNI? Any android system libraries that can be used? c,c++?

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
newWifiInfo = wifiManager.getConnectionInfo();

from there you can get the BSSID by doing

newWifiInfo.getBSSID()

then "blacklist" by turning off the wifi via

wifiManager.setWifiEnabled(false)

Also don't forget your permissions

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>

If you want more control over your wifi state, you can use the following library to "sniff" your connection and other things

https://github.com/pwittchen/ReactiveNetwork

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM