title: Android getActiveNetwork always returns null
body: <p>I am developing a Tango Application with Unity and the Tango SDK, however, I need to be able to check the device's Wifi connectivity and connect to a Wifi Network accordingly. </p>
  
  <p>With that in mind I started working on an Android Unity Network Plugin, but I am having troubles checking the device's connectivity; even though Wifi is on and the Device is indeed connected to a Wifi network, getActiveNetwork keeps returning null. </p>
  
  <p>I spent a couple of days searching for a workaround, or an alternative implementation, but I couldn't find anything that works, below is the code I ended up using to perform the check after looking through the many Android Connectivity related questions I looked at, as well as all the permissions I am using in the Manifest. </p>
  
  <p>(I would like to point out that I am currently returning an integer as a means to quickly debug the function when called via Unity C# Scripts, and right now the function always returns 0.)</p>
  
  <pre><code> public int IsConnectedToWifi(){
  
          //SCCActivity activity = new SCCActivity();
          ConnectivityManager cm = (ConnectivityManager) this.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
          if(cm == null) return  -2;
          NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
  
  
          if (activeNetwork != null) { // connected to the internet
              if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
                  // connected to wifi
                  DebugToast(activeNetwork.getTypeName());
                  return 1;
                  //return activeNetwork.isConnected();
              } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
                  // connected to the mobile provider's data plan
                  DebugToast(activeNetwork.getTypeName());
                  return 2;
                  //return false;
              }
          }
          else {
             DebugToast("There is no active Network");
              return 0;
              //return false;
          }
  
          DebugToast("Failed to get a Connectivity Manager");
          return -1;
          //return false;
      }
  </code></pre>
  
  <p>In AndroidManifest file:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/&gt;
  </code></pre>
  
  <p>I would really appreciate any advice or guidance, thank you. </p>