相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams You can not use emulator for bluetooth. And it works on device then why do you want to run it on emulator ? Ketan Ahir Mar 24, 2014 at 8:31

You can't. The emulator does not support Bluetooth, as mentioned in the SDK's docs and several other places. Android emulator does not have bluetooth capabilities ".

You can only use real devices.

Emulator Limitations

The functional limitations of the emulator include:

  • No support for placing or receiving actual phone calls. However, You can simulate phone calls (placed and received) through the emulator console
  • No support for USB
  • No support for device-attached headphones
  • No support for determining SD card insert/eject
  • No support for WiFi, Bluetooth, NFC
  • Refer to the documentation

    Download Androidx86 from this This is an iso file, so you'd
    need something like VMWare or VirtualBox to run it When creating the virtual machine, you need to set the type of guest OS as Linux instead of Other.

    After creating the virtual machine set the network adapter to 'Bridged'. · Start the VM and select 'Live CD VESA' at boot.

    Now you need to find out the IP of this VM. Go to terminal in VM (use Alt+F1 & Alt+F7 to toggle) and use the netcfg command to find this.

    Now you need open a command prompt and go to your android install folder (on host). This is usually C:\Program Files\Android\android-sdk\platform-tools>.

    Type adb connect IP_ADDRESS. There done! Now you need to add Bluetooth. Plug in your USB Bluetooth dongle/Bluetooth device.

    In VirtualBox screen, go to Devices>USB devices. Select your dongle.

    Done! now your Android VM has Bluetooth. Try powering on Bluetooth and discovering/paring with other devices.

    Now all that remains is to go to Eclipse and run your program. The Android AVD manager should show the VM as a device on the list.

    Alternatively, Under settings of the virtual machine, Goto serialports -> Port 1 check Enable serial port select a port number then select port mode as disconnected click ok. now, start virtual machine. Under Devices -> USB Devices -> you can find your laptop bluetooth listed. You can simply check the option and start testing the android bluetooth application .

    Source

    Installing Android in a generic emulator like VirtualBox should work, I have seen this method described several times on various places on the net. gaborous Dec 30, 2014 at 20:16 What if the host computer has a built-in BLE? Would it be possible to use that instead of the dongle from USB? mr5 Apr 6, 2017 at 7:21 Very nice, thank you! Worked in the free VMWare player. For step 3, the IP address can also be looked up in Settings -> About phone -> Status (scroll down). netcfg wasn't found on my install, though ifconfig eth0 did the trick. Maxim Paperno Apr 12, 2018 at 15:03

    It seems this has changed recently and they are now supporting Bluetooth as well in emulators with new API versions & google play services.

    I'm using API level 32 with google play services to create emulators.

    But how do you pair it with a real device? On my side the beacons are also visible, but it doesn't seem to detect the real bluetooth devices. Just Shadow May 20, 2022 at 7:28 Nope, can't pair it with real device. It is called Virtual Bluetooth for testing purpose. ZHANG Cheng Sep 14, 2022 at 5:45

    Now, in Android Studio 2022.1.1 (Electric eel) you can connect with Bluetooth between 2 emulators. Official docs from Google .

    I'm pretty sure this answer is wrong. The documentation you linked to seems to only indicate that you can test pairing with some mock bluetooth device. Not connect between emulators. Alex Telon Mar 1 at 16:45

    For Android Automotive there is a guide written here: https://source.android.com/devices/automotive/start/passthrough#bluetooth

    But it involves editing your kernel to activate bluetooth, and they testesd it with some USB Dongles only, but maybe worth a try.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .