Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions android/src/main/java/com/devstepbcn/wifi/AndroidWifiModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.widget.Toast;
import java.util.List;
import java.lang.Thread;
import java.lang.reflect.Method;
import android.net.DhcpInfo;

import org.json.JSONArray;
Expand Down Expand Up @@ -476,6 +477,33 @@ public void getDhcpServerAddress(Callback callback) {
callback.invoke(ip);
}

private boolean _isApOn() {
try {
if (this.canwriteFlag) {
Method method = wifi.getClass().getDeclaredMethod("isWifiApEnabled");
method.setAccessible(true);
return (Boolean) method.invoke(wifi);
} else {
this.forceWifiUsage(true);
this._isApOn()
}
} catch (Throwable e) {
return false;
}
}

@ReactMethod
public void isApOn(Callback successCallback, Callback errorCallback) {
try {
Method method = wifi.getClass().getDeclaredMethod("isWifiApEnabled");
method.setAccessible(true);
successCallback.invoke(_isApOn());

} catch (Throwable e) {
errorCallback.invoke(e.getMessage());
}
}

public static String longToIP(int longIp){
StringBuffer sb = new StringBuffer("");
String[] strip=new String[4];
Expand Down