目前很多厂商都会使用 wlan1 来配置热点,这样使用Android原生的接口,是拿不到热点名称和密码的,但使用命令就可以快速拿到;
首先,为避免权限问题,先
adb root
adb remount
然后 adb shell 进入设备,输入以下指令,找到热点配置信息
busybox ps | grep hostapd
然后使用 cat 看看 /data/misc/wifi/hostapd.conf
可以看到,名称和密码都能看到了。
你可以使用
File file = new File(confPath);
Properties properties = new Properties();
properties.load(new FileInputStream(file));
mSsid = properties.getProperty("ssid");
去获取了