hotspot

How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)

匆匆过客 提交于 2019-11-27 01:45:42
I know how to turn on/off wifi hot spot using reflection in android using below method. private static boolean changeWifiHotspotState(Context context,boolean enable) { try { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); Method method = manager.getClass().getDeclaredMethod("setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE); method.setAccessible(true); WifiConfiguration configuration = enable ? getWifiApConfiguration(manager) : null; boolean isSuccess = (Boolean) method.invoke(manager, configuration, enable); return isSuccess; } catch (Exception e) {

How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)

大憨熊 提交于 2019-11-26 07:42:20
问题 I know how to turn on/off wifi hot spot using reflection in android using below method. private static boolean changeWifiHotspotState(Context context,boolean enable) { try { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); Method method = manager.getClass().getDeclaredMethod(\"setWifiApEnabled\", WifiConfiguration.class, Boolean.TYPE); method.setAccessible(true); WifiConfiguration configuration = enable ? getWifiApConfiguration(manager) : null; boolean