startWifiTethering 和 startSoftAp 都是 Android 中用于启动 WiFi 热点的方法,但它们有一些区别。

  1. startWifiTethering 是 Android 8.0 及以上版本中新增的方法,而 startSoftAp 是旧方法,可以在 Android 2.2 及以上版本中使用。

  2. startWifiTethering 基于网络共享服务实现,它会在后台启动一个系统服务,并可以通过设置界面控制热点的开关和其他配置。而 startSoftAp 基于 WifiManager 实现,通过调用 WifiManager 的 setWifiApEnabled 方法启动热点,这种方式需要权限,并且可能存在兼容性问题。

  3. startWifiTethering 可以支持多种热点类型,包括无密码、WPA2-PSK 等,而 startSoftAp 只支持无密码和 WPA2-PSK 两种类型。

  4. startWifiTethering 可以在不需要用户交互的情况下启动热点,并可以在后台持续运行。而 startSoftAp 需要用户手动打开 Wifi 设置界面才能启动热点,且在应用退出后会自动关闭热点。

总的来说,startWifiTethering 相对于 startSoftAp 具有更好的兼容性和更丰富的功能,但需要注意的是,由于它是基于系统服务实现的,可能会被一些手机厂商进行定制或修改。

Android 启动 WiFi 热点:startWifiTethering 与 startSoftAp 的区别

原文地址: https://www.cveoy.top/t/topic/lERt 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录