收藏
回答

微信小程序里可以正常使用蓝牙功能,官方工具导出app后无法使用蓝牙功能?

微信小程序导出的蓝牙配置app,安卓手机上没显示给app蓝牙权限选项,无法打开蓝牙,但是在微信小程序里可以正常使用蓝牙功能,这是什么问题导致的?

  // 搜索蓝牙设备
  Searchfunction () {
    const that = this
    if (!that.data.searching) {
      wx.closeBluetoothAdapter({
        completefunction (res{
          wx.openBluetoothAdapter({
            successfunction (res{
              wx.getBluetoothAdapterState({
                successfunction (res{
                  console.log('蓝牙适配器状态:', res)
                }
              })
              wx.startBluetoothDevicesDiscovery({
                allowDuplicatesKeyfalse,
                successfunction (res{
                  that.setData({
                    searchingtrue,
                    devicesList: [],
                    IsConnectedHiddentrue
                  })
                  // 清空原始设备存储列表
                  that.data.BleDeviceList = []
                }
              })
            },
            failfunction (res{
              wx.showModal({
                title'提示',
                content'请检查手机蓝牙是否打开',
                showCancelfalse,
                successfunction () {
                  that.setData({ searchingfalse })
                }
              })
            }
          })
        }
      })
    } else {
      wx.stopBluetoothDevicesDiscovery({
        successfunction () {
          that.setData({ searchingfalse })
        }
      })
    }
  },
回答关注问题邀请回答
收藏
登录 后发表内容