I have been playing around with Android lately, and one thing that annoyed me is the emulator does not support Bluetooth (as opposed to J2ME emulator, which does).
So if you do not have an actual Android device (like me), and you want to do Bluetooth/WiFi programming, you run in to a problem.Fortunately, there is a way out – Install the Android image on a VM and use your own Bluetooth device. This is what I did:
So if you do not have an actual Android device (like me), and you want to do Bluetooth/WiFi programming, you run in to a problem.Fortunately, there is a way out – Install the Android image on a VM and use your own Bluetooth device. This is what I did:
- Download Androidx86 from http://www.android-x86.org/. This is an .iso file, so you’d need something like VMWare or VirtualBox to run it. Me, I use VirtualBox.
- 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 FilesAndroidandroid-sdkplatform-tools>.
- Type adb connect IP_ADDRESS
- There done! Now you need to add Bluetooth. Plug in your USB Bluetooth dongle.
- 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.
I found these links helpful. Perhaps you would too:
http://androiddevnotes.com/2011/03/08/1299521520000.html
http://developer.android.com/guide/topics/wireless/bluetooth.html#EnablingDiscoverability
🙂
Happy coding!