2

I tried to turn on ble using location service of google plays service apis. First I connected with successfully.

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

and inside onConnected(), I called 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);
}

but its not working. I am not even getting the popup. Am I missing something? Or is there any other location based services apis which can turn on ble.

Tim Tisdall
  • 9,914
  • 3
  • 52
  • 82
C B
  • 21
  • 2

0 Answers0