How to use Bluetooth in Android emulator?

Viewed 94002

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

 BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();

the adapter is returning null value, which means the android emulator is not having bluetooth capability. i am using android 2.1 the latest version of android.Anybody knows how to use the bluetooth from android emulator, please help me.

8 Answers

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"

You can install the image from http://www.android-x86.org/ into a virtual machine (e.g. VMWare), find out it's IP address, connect manually using

adb connect <IP of VM>

And then launch your project from Eclipse by setting a "Manual" deployment target in your Debug/Run configuration. Bluetooth works in this Virtual Machine at least on my Macbook and it's reported to work with a couple of other bluetooth chipsets.

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.

Related