Skip to content

Instantly share code, notes, and snippets.

@liyinsg
Created May 29, 2016 07:28
Show Gist options
  • Save liyinsg/59360e745b14332ff195c80b9e6e4ea9 to your computer and use it in GitHub Desktop.
Save liyinsg/59360e745b14332ff195c80b9e6e4ea9 to your computer and use it in GitHub Desktop.
static private void enableSoftAP(Context context) {
try {
WifiManager wifiManager;
WifiConfiguration config = null;
wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
Method method = wifiManager.getClass().getMethod("setWifiApEnabled",
WifiConfiguration.class, Boolean.TYPE);
method.invoke(wifiManager, config, true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment