title: How to set secured hotspot in android (with password)
body: <p>I want to set the hotspot on with it's <code>ssid</code> and <code>password</code> configured because i want to share it with some devices.
  The code i am using below works fine for me but i am unable to set the password of hotspot.</p>
  
  <pre><code>if (wm.isWifiEnabled()) {
                      wm.setWifiEnabled(false);
                  }
                  WifiConfiguration wifiCon = new WifiConfiguration();
                  wifiCon.SSID = "UsmanAp";
                  wifiCon.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
                  wifiCon.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
                  wifiCon.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
                  wifiCon.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
                  try{
                      Method setWifiApMethod = wm.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
                      boolean apstatus=(Boolean) setWifiApMethod.invoke(wm, wifiCon,true);
                      Method isWifiApEnabledmethod = wm.getClass().getMethod("isWifiApEnabled"); 
                      while(!(Boolean)isWifiApEnabledmethod.invoke(wm)){};
                      Method getWifiApStateMethod = wm.getClass().getMethod("getWifiApState"); 
                      int apstate=(Integer)getWifiApStateMethod.invoke(wm);
                      Method getWifiApConfigurationMethod = wm.getClass().getMethod("getWifiApConfiguration");
                      wifiCon=(WifiConfiguration)getWifiApConfigurationMethod.invoke(wm);
                  } catch (Exception e) {
                      Log.e(this.getClass().toString(), "", e);
                  }
  </code></pre>
  
  <p>What do add in the above code to set the password of the hotspot.</p>
  
  <p>-Usman</p>