【发布时间】:2017-02-09 04:51:54
【问题描述】:
我在尝试使用 Android 手机连接蓝牙设备时遇到问题。我已经从 Google Play 测试了一个应用程序并且它可以工作,但是当我从 BluetoothSerial 本机库调用 connect 方法时它不起作用。谁能帮帮我?
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { BluetoothSerial } from 'ionic-native';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
connect() {
BluetoothSerial.isEnabled().then(res => {
BluetoothSerial.connect('20:14:02:18:17:84');
BluetoothSerial.isConnected().then(res => {
console.log(res);
}).catch(res => {
console.log('Fail2!');
console.log(res);
});
}).catch(res => {
console.log('Fail!');
});
}
}
问题已解决:我需要在连接之前列出设备
【问题讨论】:
标签: android cordova typescript bluetooth ionic2