【发布时间】:2016-06-16 17:35:05
【问题描述】:
我希望我的蓝牙设备在应用不在主视图中时保持连接。每次我打开主页选项卡或其他应用程序时,它都会断开连接。如何在暂停时保持连接?相关代码如下:
@Override
protected void onPause() {
super.onPause();
//Cancel any scans in progress
mHandler.removeCallbacks(mStopRunnable);
mHandler.removeCallbacks(mStartRunnable);
mBluetoothAdapter.stopLeScan(this);
}
private Runnable mStopRunnable = new Runnable() {
@Override
public void run() {
stopScan();
}
};
private Runnable mStartRunnable = new Runnable() {
@Override
public void run() {
startScan();
}
};
【问题讨论】:
标签: java android android-studio bluetooth bluetooth-lowenergy