2

我尝试使用 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);
}

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

4

0 回答 0