有时用户打开app后,无法接收到蓝牙广播,却不知是因为蓝牙和定位未开启,故需要在app中增加判断提示。
请求打开定位服务
private fun checkLocationSetting() {
if (!LocationSetting.isEnabled(this)) {
runOnUiThread {
LocationSetting.askToActivate(this)
}
}
}
import android.app.AlertDialog
import android.content.Context
import android.content.Context.LOCATION_SERVICE
import android.content.Intent
import