diff --git a/app/src/main/java/com/termux/api/WifiAPI.java b/app/src/main/java/com/termux/api/WifiAPI.java index 739c5c72..37c77436 100644 --- a/app/src/main/java/com/termux/api/WifiAPI.java +++ b/app/src/main/java/com/termux/api/WifiAPI.java @@ -21,7 +21,7 @@ static void onReceiveWifiConnectionInfo(TermuxApiReceiver apiReceiver, final Con ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultJsonWriter() { @Override public void writeJson(JsonWriter out) throws Exception { - WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiInfo info = manager.getConnectionInfo(); out.beginObject(); if (info == null) { @@ -53,7 +53,7 @@ static void onReceiveWifiScanInfo(TermuxApiReceiver apiReceiver, final Context c ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultJsonWriter() { @Override public void writeJson(JsonWriter out) throws Exception { - WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); List scans = manager.getScanResults(); if (scans == null) { out.beginObject().name("API_ERROR").value("Failed getting scan results").endObject();