如何启用或禁用热点以编程方式检查?

时间:2012-09-13 07:06:17

标签: android

  

可能重复:
  How to detect WiFi tethering state

我需要通过我的应用检查设备上是否有热点?

1 个答案:

答案 0 :(得分:12)

代码:

Method method = wifiManager.getClass().getDeclaredMethod("getWifiApState");
method.setAccessible(true);
int actualState = (Integer) method.invoke(wifiManager, (Object[]) null);

实际状态应为:

public static int AP_STATE_DISABLING = 10;
public static int AP_STATE_DISABLED = 11;
public static int AP_STATE_ENABLING = 12;
public static int AP_STATE_ENABLED = 13;
public static int AP_STATE_FAILED = 14;

WifiManger source code

希望这对你有所帮助!