This article describes how to manually configure a Local DHCP configuration in the HTC WiFi hotspot program com. htc. WiFiRouter to automatically obtain the IP address. But how can we implement it with code. After studying for a long time, I only need to dump all the classes unique to HTC. The Code is as follows [java] public void dumpHTCWifiFunction2 () {Log. e (TAG, "dumphtcwifunction2 ++"); // Method [] classMethods = null; Field localField1; Field [] fieldlist; WifiConfiguration apConfig = new WifiConfiguration (); try {localField1 = WifiConfiguration. class. getDeclaredField ("mWifiApProfile"); localField1.setAccessible (true); Object localObject2 = localField1.get (apConfig); LocalField1.setAccessible (false); if (localObject2! = Null) {fieldlist = localObject2.getClass (). getDeclaredFields (); for (int I = 0; I <fieldlist. length; I ++) {Log. e (TAG, "found api:" + fieldlist [I]. getName () ;}} catch (NoSuchFieldException e) {// TODO Auto-generated catch block e. printStackTrace ();} catch (IllegalArgumentException e) {// TODO Auto-generated catch block e. printStackTrace ();} catch (IllegalAccessException e) {// TODO Auto-g Enerated catch block e. printStackTrace ();} Log. e (TAG, "dumpHTCWifiFunction2 --");} 12-28 11:06:29. 956: E/MainActivity (3253): dumphtcwifunction2 ++ 12-28 11:06:29. 966: E/MainActivity (3253): found api: DEFAULT_DHCP_MAX_AP_CONNECTION12-28 11:06:29. 966: E/MainActivity (3253): found api: DEFAULT_MAX_AP_CONNECTION12-28 11:06:29. 976: E/MainActivity (3253): found api: DHCP_MAX_AP_CONNECTION12-28 11:06:29. 9 76: E/MainActivity (3253): found api: MAX_AP_CONNECTION12-28 11:06:29. 976: E/MainActivity (3253): found api: OPEN12-28 11:06:29. 976: E/MainActivity (3253): found api: WEP12-28 11:06:29. 986: E/MainActivity (3253): found api: WPA12-28 11:06:29. 986: E/MainActivity (3253): found api: WPA212-28 11:06:29. 986: E/MainActivity (3253): found api: BSSID12-28 11:06:29. 996: E/MainActivity (3253): found api: SSID12-28 11:06:29. 996: E/MainActivity (3253): found api: blocklist12-28 11:06:29. 996: E/MainActivity (3253): found api: whitelist12-28 11:06:29. 996: E/MainActivity (3253): found api: this $012-28 11:06:30. 006: E/MainActivity (3253): found api: startingIP12-28 11:06:30. 006: E/MainActivity (3253): found api: dhcpSubnetMask12-28 11:06:30. 016: E/MainActivity (3253): found api: dnsIPAddr112-28 11:06:30. 016: E/MainAct Ivity (3253): found api: dnsIPAddr212-28 11:06:30. 016: E/MainActivity (3253): found api: secureType12-28 11:06:30. 016: E/MainActivity (3253): found api: key12-28 11:06:30. 016: E/MainActivity (3253): found api: ipAddress12-28 11:06:30. 016: E/MainActivity (3253): found api: hiddenSSID12-28 11:06:30. 016: E/MainActivity (3253): found api: maxConns12-28 11:06:30. 016: E/MainActivity (3253): found api: maxDhcpC Lients12-28 11:06:30. 026: E/MainActivity (3253): found api: enableMacFilter12-28 11:06:30. 026: E/MainActivity (3253): found api: sleepPolicy12-28 11:06:30. 026: E/MainActivity (3253): found api: dhcpEnable12-28 11:06:30. 026: E/MainActivity (3253): found api: connectionArray12-28 11:06:30. 026: E/MainActivity (3253): found api: channel12-28 11:06:30. 026: E/MainActivity (3253): dumpHTCWifiFunction2 -- dh discovered CpEnable: The member variable. It was a boolean variable at the beginning, but it is wrong. It will occur during the setting. Simply print out its type and change the print statement to Log. e (TAG, "found api:" + fieldlist [I]. getName () + "type:" + fieldlist [I]. toString (); found api: dhcpEnable type: public int android.net. wifi. wifiConfiguration $ HotspotProfile. dhcpEnable is an int type variable. Assume that 1 is enable. after setting, you can. Complete code: [java] private boolean setWifiSSIDForHTC (WifiConfiguration apConfig) {boolean successed = true; // WifiConfiguration mnetConfig = new WifiConfiguration (); Field localField1; try {localField1 = WifiConfiguration. class. getDeclaredField ("mWifiApProfile"); localField1.setAccessible (true); Object localObject2 = localField1.get (apConfig); localField1.setAccessible (false); if (localObject2! = Null) {Field localField5 = localObject2.getClass (). getDeclaredField ("SSID"); localField5.setAccessible (true); localField5.set (localObject2, apConfig. SSID); // netConfig. SSID); localField5.setAccessible (false); Field localField4 = localObject2.getClass (). getDeclaredField ("BSSID"); localField4.setAccessible (true); localField4.set (localObject2, apConfig. BSSID); // netConfig. BSSID); localField4.setAccessible (false); Field localField6 = localObject2.getClass (). getDeclaredField ("dhcpEnable"); localField6.setAccessible (true); // localField6.set (localObject2, "true"); // netConfig. BSSID); localField6.setInt (localObject2, 1); localField6.setAccessible (false) ;}} catch (Exception e) {e. printStackTrace ();} return successed ;}