如何使用谷歌播放服务apis打开BLE

时间:2015-12-08 06:11:05

标签: bluetooth-lowenergy android-ble

我尝试使用google play service apis的位置服务打开ble。首先,我成功连接。

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addApi(LocationServices.API)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build(); 
         mGoogleApiClient.connect();

在onConnected()内部,我调用了setNeedBle(true):

public void onConnected(Bundle arg0) {
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
        builder.setNeedBle(true);
        LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
        bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        mBluetoothAdapter = bluetoothManager.getAdapter();
        mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
        Log.d("TAG100","inside setNeedBle "+mLEScanner);
        settings = new             ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
        mHandler = new Handler();
        filters = new ArrayList<ScanFilter>();
        scanLeDevice(true);
}

但它不起作用。我甚至没有得到弹出窗口。 我错过了什么吗? 或者是否有任何其他基于位置的服务apis可以打开。

0 个答案:

没有答案