mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -04:00
Add method getWifiApState() and isWifiApEnabled()
It's used to get current state of wifi access point.
This commit is contained in:
parent
8eff3c5d84
commit
bd328b5d1d
@ -45,6 +45,28 @@ public class WifiHotspotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WIFI_AP_STATE_ENUMS getWifiApState() {
|
||||||
|
try {
|
||||||
|
Method method = wifiManager.getClass().getMethod("getWifiApState");
|
||||||
|
|
||||||
|
int tmp = ((Integer) method.invoke(wifiManager));
|
||||||
|
|
||||||
|
// Fix for Android 4
|
||||||
|
if (tmp >= 10) {
|
||||||
|
tmp = tmp - 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WIFI_AP_STATE_ENUMS.class.getEnumConstants()[tmp];
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(this.getClass().toString(), "", e);
|
||||||
|
return WIFI_AP_STATE_ENUMS.WIFI_AP_STATE_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWifiApEnabled() {
|
||||||
|
return getWifiApState() == WIFI_AP_STATE_ENUMS.WIFI_AP_STATE_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
public WifiConfiguration getWifiApConfiguration() {
|
public WifiConfiguration getWifiApConfiguration() {
|
||||||
try {
|
try {
|
||||||
Method method = wifiManager.getClass().getMethod("getWifiApConfiguration");
|
Method method = wifiManager.getClass().getMethod("getWifiApConfiguration");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user