Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.

Commit 311e0da

Browse files
lakshyagupta21lognaturel
authored andcommitted
Disable existing wifi connection before connecting hotspot (#90)
1 parent ff4a41b commit 311e0da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

share_app/src/main/java/org/odk/share/activities/SendActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.widget.Toast;
2020

2121
import org.odk.share.R;
22+
import org.odk.share.controller.WifiHelper;
2223
import org.odk.share.controller.WifiHotspotHelper;
2324
import org.odk.share.events.HotspotEvent;
2425
import org.odk.share.events.UploadEvent;
@@ -100,6 +101,10 @@ protected void onCreate(Bundle savedInstanceState) {
100101
Timber.e("Port not available for socket communication");
101102
finish();
102103
}
104+
WifiHelper wifiHelper = new WifiHelper(this);
105+
if (wifiHelper.getWifiManager().isWifiEnabled()) {
106+
wifiHelper.disableWifi(null);
107+
}
103108

104109
isHotspotInitiated = false;
105110
isHotspotRunning = false;

share_app/src/main/java/org/odk/share/controller/WifiHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ private void removeNetworkAndEnableOther(String ssid) {
9292
}
9393

9494
public void disableWifi(String ssid) {
95-
removeNetworkAndEnableOther(ssid);
95+
if (ssid != null) {
96+
removeNetworkAndEnableOther(ssid);
97+
}
9698
wifiManager.setWifiEnabled(false);
9799
}
98100

0 commit comments

Comments
 (0)