summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-05-14 22:08:48 +0200
committerDaniel Weipert <code@drogueronin.de>2023-05-14 22:08:48 +0200
commitde738691db03ff61bf292b75bfa716b75fe34af1 (patch)
tree156c1a0da21147fa5c1e80c251cb918636392ea5
parent6f4dc54bd119203da8dd1f91e65c4e4b99ab2ff0 (diff)
delay start of proxy service on network change
-rw-r--r--app/java/src/WifiListenerReceiver.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/app/java/src/WifiListenerReceiver.java b/app/java/src/WifiListenerReceiver.java
index e8ebedf..ca22965 100644
--- a/app/java/src/WifiListenerReceiver.java
+++ b/app/java/src/WifiListenerReceiver.java
@@ -11,6 +11,7 @@ import android.net.wifi.WifiManager;
import android.net.wifi.WifiInfo;
import android.os.Bundle;
+import android.os.Handler;
import android.util.Log;
@@ -23,12 +24,18 @@ public class WifiListenerReceiver extends BroadcastReceiver
// start
if (networkInfo.getState().equals(NetworkInfo.State.CONNECTED)) {
- WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- WifiInfo wifiInfo = wifiManager.getConnectionInfo();
-
- // if (wifiInfo.getSSID() == setting.get(LOCAL_HOME_WIFI_SSID))
-
- context.startService(dnsProxyService.setAction(DNSProxyService.ACTION_START));
+ // wait a few moments for wifi to be fully there
+ (new Handler()).postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wifiInfo = wifiManager.getConnectionInfo();
+
+ // if (wifiInfo.getSSID() == setting.get(LOCAL_HOME_WIFI_SSID))
+
+ context.startService(dnsProxyService.setAction(DNSProxyService.ACTION_START));
+ }
+ }, 1000);
}
// stop