我想用蓝牙制作一个安卓应用程序,经过一些研究后,我发现了这。我从未使用过ANE,但据我所知,它的实现非常类似于使用SWC。在将ANE复制到.\lib路径并将其包括在我的项目中之后,我尝试按照网站上的建议扫描设备:
if (Bluetooth.isSupported) {
trace("1!");
bt = Bluetooth.currentAdapter();
trace("2!");
bt.addEventListener(BluetoothScanEvent.BLUETOOTH_DISCOVERY_STARTED, bluetoothScanEventHandeler);
bt.addEventListener(BluetoothScanEvent.BLUETOOTH_DEVICE_FOUND, bluetoothScanEventHandeler);
bt.addEventListener(BluetoothScanEvent.BLUETOOTH_DISCOVERY_FINISHED, bluetoothScanEventHandeler);
bt.scanForVisibleDevices();
}因为某种原因,我得到了错误
Error #1009: Cannot access a property or method of a null object reference.我所包含的跟踪指向bt = Bluetooth.currentAdapter();,但是如果我将Bluetooth.isSupported更改为Bluetooth.isSupported(),则会得到相同的错误。
我已经确保该项目的Adobe应用程序描述符文件模板(应用程序xmlns)与ANE匹配。
没有其他人有同样的问题,救命?
发布于 2013-11-21 23:49:20
我看到你在使用闪存开发,我不熟悉,但听起来BlueTooth是空的。通常,ANEs是单子,并且有一个getInstance()方法。一旦创建了单个实例,BlueTooth就不再为null,您应该能够访问它的其余方法。
在你的项目中,你通常会像.
var blueTooth:BlueTooth = Bluetooth.getInstance();
if(BlueTooth.isSupported)
{
}或
if(BlueTooth.isSupported)
{
bt = BlueTooth.getInstance().currentAdapter();
}https://stackoverflow.com/questions/20130650
复制相似问题