title: AndroidStudio: BroadcastReceiver for established Wifi connection shows no result
body: <br>
  I am building a Smart Home system for me which uses a RaspberryPi as a central managing station in the home where a server is running that manages all data requests or sensor informations from all other devices within the Smart Home system. One of those devices is my smartphone, an android device. I designed an app where I can see all important information of my Smart Home. <br><br>
  Now, when I enter the house and when my smartphone is connected to the Wifi, I want it to connect to the Smart Home server on the RaspberryPi to load current information or eventually generate a notification for me. Therefore, I created a BroadcastReceiver which should now activate the app to do what I want at the moment when the smartphone has a Wifi connection. However, that does not work and I don't know why. <br>
  <br>
  <b>In my "AndroidManifest.xml" file I inserted that tag into the application tag:</b>
  <br>
  <p><a href="https://i.stack.imgur.com/oCFx1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oCFx1.png" alt="A receiver tag whith an intent-filter tag and three action tags" /></a></p>
  <pre><code>&lt;receiver android:name=&quot;com.example.test.checking.ConnectivityReceiver&quot;&gt;
          &lt;intent-filter android:priority=&quot;100&quot;&gt;
              &lt;action android:name=&quot;android.net.wifi.STATE_CHANGE&quot; /&gt;
              &lt;action android:name=&quot;android.net.wifi.WifiManager.NETWORK_STATE_CHANGED_ACTION&quot; /&gt;
              &lt;action android:name=&quot;android.net.conn.CONNECTIVITY_CHANGE&quot; /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  <p><br><br>
  <strong>The following class is my BroadcastReceiver:</strong>
  <a href="https://i.stack.imgur.com/rCiTn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCiTn.png" alt="enter image description here" /></a></p>
  <pre><code>package com.example.test.checking;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  
  public class ConnectivityReceiver extends BroadcastReceiver {
  
  public static final String CHANNEL_ID = &quot;wifi_connection_channel&quot;;
  
      @Override
      public void onReceive(Context context, Intent intent) {
          System.out.println(&quot;Wificonnection established! I am happy!&quot;);
      }
  }
  </code></pre>
  <p><strong>In my &quot;AndroidManifest.xml&quot; I also declared the permissions:</strong></p>
  <p><a href="https://i.stack.imgur.com/ZKF29.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZKF29.png" alt="enter image description here" /></a></p>
  <br>
  I just put in a console output when the receiver's method is called but when I start a debug and turn off or on the Wifi connection on my smartphone, there is no message in the console. I've also tested a notification to be sent or an activity to be started but that did not work too.<br>
  <br>
  Does anybody see what is my fault?<br>
  Thanks a lot!
  <p><strong>So the problem now is that I could register a broadcast receiver but only one that stays online while the app is opened or at least not fully closed. I do that using <code>getApplicationContext().registerReceiver(BroadcastReceiver, IntentFilter)</code>. Does anyone know how to create somethin (not necessarily a BroadcastReceiver) that checks the connection to the Smart Home server when a Wifi connection is established?</strong></p>