V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
philon
V2EX  ›  Android

Android 手机是否有像 iPhone 一样的后台蓝牙 BLE 广播

  •  
  •   philon · Oct 7, 2020 · 13650 views
    This topic created in 2031 days ago, the information mentioned may be changed or developed.

    本人对 Android 及 iOS 不熟,由于项目需要,一个设备通过蓝牙扫描周围的手机,有点类似于 Wi-Fi 探针的功能。

    我发现 iOS 系统后台会对外进行 BLE 广播,而 Android 生态下手机厂商太多,尽管 Android 号称支持 BLE 以及 iBeacon,但貌似不是每款手机都能被扫描到。

    我的问题很简单: Android 系统本身是否存在个 BLE 广播的后台,还是需要开发 APP 自己进行广播?

    5 replies    2020-10-15 15:39:22 +08:00
    rebounce
        1
    rebounce  
       Oct 7, 2020 via iPhone
    Android8.0 后,息屏不能。
    azh7138m
        2
    azh7138m  
       Oct 7, 2020
    没有发现 iOS 会在后台做广播
    而且 iOS 也不允许应用在后台做 iBeacon 广播
    你能搜到只是因为 iOS 的蓝牙没有关,设置里面关掉就搜不到了

    回到问题本身
    需要自己开发
    rb6221
        3
    rb6221  
       Oct 8, 2020
    蓝牙探针是吧?刚好前几天看了篇文章,还有源码 你可以研究下
    www.infoq.cn/article/HRK0oRWhdyV5vU30gWlW
    philon
        4
    philon  
    OP
       Oct 8, 2020
    @janus77 感谢你的分享,我想知道的只是 Android 系统自身是否有个蓝牙广播后台。
    LLaMA2
        5
    LLaMA2  
       Oct 15, 2020
    BLE 分为 Peripheral 和 Central 模式
    对应起来有点类似 Peripheral(Server) 和 Central ( Client )
    大于 4.4 的设备可以开启 Peripheral 外围模式
    你需要打开手机的 BlueTooth 并给予 ACCESS_COARSE_LOCATION 和 ACCESS_FINE_LOCATION 权限
    否则 Central 中心模式的设备无法扫描到你

    Peripheral 开启前你需要准备好 BLE 的 BluetoothGattService,和该 service 下的 BluetoothGattCharacteristic,以及 characteristic 下的 BluetoothGattDescriptor

    其次 BluetoothGattCharacteristic 分为可读 可写,BluetoothGattDescriptor 分为可读可写可通知可指示

    至于 Central 模式,网络上的 Demo 很多
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1330 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 17:04 · PVG 01:04 · LAX 10:04 · JFK 13:04
    ♥ Do have faith in what you're doing.