Android examples for Phone:wifi
close Wifi Ap
//package com.java2s; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { private static WifiManager mWifiManager; public static void closeWifiAp() { if (isWifiApEnabled()) { try { Method method = mWifiManager.getClass().getMethod( "getWifiApConfiguration"); method.setAccessible(true); WifiConfiguration config = (WifiConfiguration) method .invoke(mWifiManager); Method method2 = mWifiManager.getClass().getMethod( "setWifiApEnabled", WifiConfiguration.class, boolean.class); method2.invoke(mWifiManager, config, false); } catch (NoSuchMethodException e) { } catch (IllegalArgumentException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { }// w w w . j av a2s . c om } } public static boolean isWifiApEnabled() { try { Method method = mWifiManager.getClass().getMethod( "isWifiApEnabled"); method.setAccessible(true); return (Boolean) method.invoke(mWifiManager); } catch (NoSuchMethodException e) { } catch (Exception e) { } return false; } }