title: Turn on/off WiFi hotspot programmatically
body: <p>I need help in creating a C# script that set a android WiFi in hotspot mode. Here is the code that I managed to create.</p>
  
  <pre><code>    public bool setAPEnabled(bool enabled)
  {
      using (AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic&lt;AndroidJavaObject&gt;("currentActivity"))
      {
          try
          {
              if(isWifiEnabled()==true){
                  setWifiEnabled(false);
              }
              using (var wifiManager = activity.Call&lt;AndroidJavaObject&gt;("getSystemService", "wifi"))
              {
                  return wifiManager.Call&lt;bool&gt;("setWifiApEnabled",null, enabled);
              }
          }
          catch (Exception e)
          {
          }
      }
      return false;
  }
  </code></pre>
  
  <p>Everything works well - but I have a problem with setting the SSID and password. After reviewing the <a href="https://developer.android.com/reference/android/net/wifi/WifiConfiguration.html" rel="nofollow noreferrer">documentation</a> I know that I have to replace my null value with the settings object, but I completely don't know how to do it in Unity.</p>