如果你需要连接测量设备,来测量,比如血压,血氧等指标,那么,这个时候应该先去检查,蓝牙有没有
打开,如果没有打开,给予用户提示,而不是一直在那转圈.
1.首先检查系统是否已经开启定位
/**
* 手机是否开启位置服务,如果没有开启那么所有app将不能使用定位功能
*/
public boolean isLocServiceEnable(Context context) {
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (gps || network) {
return true;
}
return false;
}
2.然后再去检查是否已经开启蓝牙:
当然要使用蓝牙,首先要获取蓝牙权限,这里蓝牙权限的配置,就不多说了,文章太多,找个复制过来用
就可以了.
这里说一下代码部分:
private Bl