安卓通过反射开关个人热点

 Wifi模块—源码分析Wifi热点的开启(Android P)

Java反射开关个人热点

    public void hotPointOpen(boolean open){
        if (open) {
            insertLog("open hot point by api");
            try {
                wifiManager.getClass().getMethod("startSoftAp", WifiConfiguration.class).invoke(wifiManager, (WifiConfiguration) null);
            } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                e.printStackTrace();
            }
        }else {
            insertLog("close hot point by api");
            try {
                wifiManager.getClass().getDeclaredMethod("stopSoftAp").invoke(wifiManager);
            } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                e.printStackTrace();
            }
        }
    }

你可能感兴趣的:(安卓自动化测试,android,windows)