1 问题
在Android8.0手机开启了热点,关闭页面再次打开热点,
/**
* 开启Android8.0版本手机以上的热点,热点名字和密码都是随机的。
*/
fun initWifiApGreaterThanEight(context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
var wifiManager:WifiManager = getApplicationContext().getSystemService(Context.WIFI_SERVICE) as WifiManager
try {
wifiManager.startLocalOnlyHotspot(object : WifiManager.LocalOnlyHotspotCallback(){
override fun onStarted(reservation: WifiManager.LocalOnlyHotspotReservation?) {
super.onStarted(reservation)
Log.i(TAG, "uild.VERSION.SDK_INT >= Build.VERSION_CODES.O initWifiAp onStarted");
reserva = reservation
var wifiConfiguration = reservation!!.wifiConfiguration
var ssid = wifiConfiguration.SSID;