1

我正在开发钛合金项目。 我需要使用Beacon模块使用BLE扫描信标。 我的问题是,我无法让模块工作。在钛合金中使用模块

我使用了安装移动模块安装模块,我启用它在tiapp.xml文件。

这是代码,我目前的样子:

var Beacons = require('com.logicallabs.beacons'); 

function doClick(beacon) { 
    if(Beacons.BeaconsModule.isEnabled()){ 
     alert('succes'); 
    }else{ 
     alert("suces"); 
    } 
} 

$.index.open(); 

当你点击一个标签的功能被启动。该模块包含3个类。你必须指定你必须使用哪一类的极大方法?

而且当我开始这个节目,我得到错误说Could not find class 'android.bluetooth.BluetoothManagerCould not find class 'com.logicallabs.beacons.ScanService$2

回答

0

下面是略加修改从示例应用程序代码包含在模块,安装:

var Beacons = require('com.logicallabs.beacons'); 

function log(text) { 
    Ti.API.info(text); 
} 

if (Beacons.isSupported()) { 
    log('Bluetooth is supported!'); 

    if (Beacons.isEnabled()) { 
     log('Bluetooth is already enabled!'); 
    } else { 
     log('Bluetooth is disbled; enabling now.'); 
     // This will eventually fire a stateChanged event with state set to 
     // STATE_ON, at which point we start the scanning. 
     Beacons.enable(); 
    } 
} else { 
    log('Bluetooth LE is not supported.');    
} 

有关详情,请文档和示例应用程序。在OSX上,您可以在~/Library/Application Support/Titanium/modules/android/com.logicallabs.beacons/目录中找到它。

+0

我仍然得到错误找不到类“android.bluetooth.BluetoothManager和找不到类” com.logicallabs。 beacons.ScanService港币$ 16。我在Android设备上进行调试,因为我无法使仿真器正常工作。它可能是我的android的问题? – Ken

0

,如果你与Android API版本的设备上测试它只会工作,为> = 18