C++Builder 11 如何运态申请蓝牙的SCAN,ADVERTISE,CONNECT这三个权限

qq_40074471 2024-11-19 12:21:02

  手机运行了app,出错,android.permission.BLUETOOTHCONNECT permission for android
  这3个权限都是从Android 12系统才开始有的,
 经过网上一番查找,原来是因为最近Google发布的Android 12,
 新引入了 BLUETOOTH_SCAN、BLUETOOTH_CONNECT、BLUETOOTH_ADVERTISE 三个权限
 Manifest.permission.BLUETOOTH_SCAN,
 Manifest.permission.BLUETOOTH_ADVERTISE,
Manifest.permission.BLUETOOTH_CONNECT

C++Builder 11 如何运态申请蓝牙的这三个权限,

bool __fastcall DiscoverDevices(int ATimeout)/* overload */;
bool __fastcall DiscoverDevices(int ATimeout, System::Bluetooth::TBluetoothUUIDsList* const AList)/* overload */;
bool __fastcall DiscoverDevices(int ATimeout, GUID *AList, const int AList_High)/* overload */;
bool __fastcall DiscoverDevices(unsigned ATimeout, System::Bluetooth::TBluetoothLEScanFilterList* const ABluetoothLEScanFilterList)/* overload */;
Bluetooth::TBluetoothUUIDsList * TBluetoothUUID = "{0000180D-0000-1000-8000-00805F9B34FB}";
BluetoothLE1->DiscoverDevices(2500);                                 //2500毫秒的查找时间

应该是上述的函数,问:有操作实际例子?

大家有用过的,请帮助...

...全文
187 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复

https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Bluetooth.Components.TBluetoothLE.DiscoverDevices
这个还要什么例子,调用DiscoverDevices(过滤或者不过滤),提供一个OnEndDiscoverDevices事件处理过程就可以了
这个事件触发的时候,参数中包含了发现的蓝牙设备的列表
大概从安卓7开始,敏感权限大部分都是动态权限,在安装时获得的权限,运行时还是要弹出对话框要用户授权才行。
你在Manifest文件里添加权限,运行时检查返回值(按上面的说明,windows、macos、ios总是返回true,android可能返回false,如果用户拒绝授权的话)。

ooolinux 2024-11-21
  • 打赏
  • 举报
回复

Delphi 盒子论坛 问问看

13,864

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧