From 35cfb76cc20382e856ae95535243030d9a4bff08 Mon Sep 17 00:00:00 2001 From: Chromicle Date: Sat, 30 Nov 2019 22:05:26 +0530 Subject: [PATCH] :ambulance: Fixed crash while sending forms --- .../views/ui/hotspot/HpSenderActivity.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/hotspot/HpSenderActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/hotspot/HpSenderActivity.java index 859db6ba..c29a99ff 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/hotspot/HpSenderActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/hotspot/HpSenderActivity.java @@ -373,29 +373,31 @@ private void startSending() { @RequiresApi(api = Build.VERSION_CODES.O) private void turnOnHotspot() { - WifiManager manager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); - manager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() { - - @Override - public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) { - super.onStarted(reservation); - hotspotReservation = reservation; - currentConfig = reservation.getWifiConfiguration(); - startSending(); - } + if (!isHotspotInitiated) { + WifiManager manager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); + manager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() { + + @Override + public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) { + super.onStarted(reservation); + hotspotReservation = reservation; + currentConfig = reservation.getWifiConfiguration(); + startSending(); + } - @Override - public void onStopped() { - super.onStopped(); - Timber.d("Local Hotspot Stopped"); - } + @Override + public void onStopped() { + super.onStopped(); + Timber.d("Local Hotspot Stopped"); + } - @Override - public void onFailed(int reason) { - super.onFailed(reason); - Timber.d("Local Hotspot failed to start"); - } - }, new Handler()); + @Override + public void onFailed(int reason) { + super.onFailed(reason); + Timber.d("Local Hotspot failed to start"); + } + }, new Handler()); + } } @RequiresApi(api = Build.VERSION_CODES.O)