我研究了关于蓝牙低功耗 http://developer.android.com/guide/topics/connectivity/bluetooth-le.html.
但我没有支持 BLE 设备进行测试。
因此,我想问:
Android模拟器支持BLE功能进行测试吗?
我尝试使用以下代码Android 模拟器 4.3 (x86) 和 Android 模拟器 4.4 (ARM):
// Use this check to determine whether BLE is supported on the device. Then
// you can selectively disable BLE-related features.
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
finish();
}
And it 始终显示“ble_not_supported”.
另一个问题是
哪个模拟器或工具支持 Android BLE?
我真的很想在模拟器上测试 BLE 功能。
看来你可以,在 VirtualBox 中使用 Android 并使用支持蓝牙 LE 的 PC 适配器(在亚马逊上售价约为 18 美元)。这是克里斯·拉尔森的教程 http://chrislarson.me/blog/emulate-android-and-bluetooth-le-hardware.html(复制到此处以保持在线状态):
Android 模拟器非常适合开发蓝牙 LE 应用程序。
诀窍是让 Android 模拟器识别 BluetoothLE
适配器。
你需要什么:
- 来自 android-x86.org 的 Androidx86 iso 我使用了 4.4 候选版本
- 虚拟机软件:我用的是Oracle VirtualBox
- 蓝牙 LE USB 适配器:我使用了 Cirago 蓝牙 4.0 USB 迷你适配器 (BTA8000)(附属链接)或 Cirago 蓝牙 4.0 USB 迷你
适配器 (BTA8000)(非附属链接)
- 安装Android SDK进行调试
- 安装VirtualBox
- 下载Androidx86
- 打开 VirtualBox 并创建一台新机器。将类型设置为 linux/other(32bit)
- 将虚拟机的内存和硬盘空间设置为您需要的任何值(但至少是 Android 的最低规格)。
- 当询问操作系统映像时,选择您从 Androidx86.org 下载的 Androidx86 映像
- 虚拟机启动后,选择安装Android。
- 安装完成后,关闭Android虚拟机并卸载iso镜像
- 插入蓝牙 USB 适配器并将其添加到 Android 虚拟机的设置中
- 启动 Android 虚拟机并浏览启动屏幕以配置 Android 以供使用
- 在 Android VM 中,转到设置并启用 BluetoothLE(如果失败,请重新启动 VM 并尝试再次启用)
以下是一些其他链接,或多或少描述了相同的方法,以及您可能感兴趣的其他一些工具:
- http://technoga.wordpress.com/2013/05/06/debug-a-bluetooth-app-with-android-emulator-on-pc/ http://technoga.wordpress.com/2013/05/06/debug-a-bluetooth-app-with-android-emulator-on-pc/
- http://niro-offonatangent.blogspot.fr/2011/06/bluetooth-support-on-android-emulator.html http://niro-offonatangent.blogspot.fr/2011/06/bluetooth-support-on-android-emulator.html
- http://referenceforu.blogspot.fr/2013/08/testing-bluetooth-in-android-emulator.html http://referenceforu.blogspot.fr/2013/08/testing-bluetooth-in-android-emulator.html
- https://stackoverflow.com/a/2614840/1121352 https://stackoverflow.com/a/2614840/1121352
- https://github.com/heng81/Android-蓝牙-模拟器 https://github.com/cheng81/Android-Bluetooth-Simulator
- 一组用于在 Android 上开发蓝牙 LE 应用程序的开源工具:https://github.com/grundid/bletools https://github.com/grundid/bletools and http://blog.opendatalab.de/hack/2013/11/15/bluetooth-low-energy-tools-library-for-android/ http://blog.opendatalab.de/hack/2013/11/15/bluetooth-low-energy-tools-library-for-android/
如果你希望谷歌解决这个问题,你可以给这个帖子加注星标,让它更加明显(只要有足够的选票,谷歌将在几年内解决这个问题,就像他们处理音频问题一样......):
https://code.google.com/p/android/issues/detail?id=56608 https://code.google.com/p/android/issues/detail?id=56608
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)