How to use Bluetooth in Android emulator?

前端 未结 8 1926
醉梦人生
醉梦人生 2020-11-29 03:14

I want to create an application based on bluetooth operation in android.I am using the following code

 BluetoothAdapter adapter=BluetoothAdapter.getDefaultAd         


        
相关标签:
8条回答
  • 2020-11-29 03:51

    The emulator doesnt support bluetooth as mentioned in the sdk's docs. You have to check this in real device..

    And you got error Bluetooth binder is null. it means emulator does not have bluetooth capability.

    0 讨论(0)
  • 2020-11-29 03:56

    You can't. The emulator does not support Bluetooth, as mentioned in the SDK's docs and on several other places.

    And you already discovered this yourself: "the adapter is returning null value, which means the android emulator is not having bluetooth capability"

    0 讨论(0)
  • 2020-11-29 04:03

    I'm currently planning a tool that is capable of emulating Bluetooth over TCP/IP under Linux (will be released freely under GPL).

    This should be the solution when not having a real Bluetooth device (e.g. you want to simulate a connection between two emulated Android-x86 or Linux machines).

    Maybe when compiling for Linux-ARM instead of Linux-x86 it will run in the Emulator, too.

    0 讨论(0)
  • 2020-11-29 04:05

    It's not possible to run bluetooth aap on emulator.as there is no support for bluetooth on emulator. look at this http://developer.android.com/guide/developing/devices/emulator.html Emulator Limitations

    In this release, the limitations of the emulator include:

    • No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however.
    • No support for USB connections
    • No support for camera/video capture (input).
    • No support for device-attached headphones
    • No support for determining connected state
    • No support for determining battery charge level and AC charging state
    • No support for determining SD card insert/eject
    • No support for Bluetooth
    0 讨论(0)
  • 2020-11-29 04:08

    You can but you will need to run your app on an Android inside a VirtualBox or VMWare image. For more infos, see here (tutorial is for Bluetooth LE, but it works just the same with other Bluetooth versions): Bluetooth Low Energy on Android Emulator

    0 讨论(0)
  • 2020-11-29 04:09

    Yes, I agree, right now the emulator does not support Bluetooth.

    To compile Android with Bluetooth support enabled, add the following line to BoardConfig.mk.

    BOARD_HAVE_BLUETOOTH := true
    
    0 讨论(0)
提交回复
热议问题