private void startScan(final ScannerStateLiveData state) {
        if (Utils.isBluetoothScanAndConnectPermissionsGranted(this)) {
            binding.noBluetoothPermissions.getRoot().setVisibility(View.GONE);
            // First, check the Location permission. This is required on Marshmallow onwards in order to scan for Bluetooth LE devices.
            if (Utils.isLocationPermissionsGranted(this)) {
                binding.noLocationPermission.getRoot().setVisibility(View.GONE);

                // Bluetooth must be enabled
                if (state.isBluetoothEnabled()) {
                    binding.bluetoothOff.getRoot().setVisibility(View.GONE);

                    if (!state.isScanning()) {
                        // We are now OK to start scanning
                        if (mScanWithProxyService) {
                            mViewModel.getScannerRepository().startScan(BleMeshManager.MESH_PROVISIONING_UUID);
                        } else {
                            mViewModel.getScannerRepository().startScan(BleMeshManager.MESH_PROXY_UUID);
                        }
                        binding.stateScanning.setVisibility(View.VISIBLE);
                    }

                    if (state.isEmpty()) {
                        binding.noDevices.getRoot().setVisibility(View.VISIBLE);

                        if (!Utils.isLocationRequired(this) || Utils.isLocationEnabled(this)) {
                            binding.noLocationPermission.getRoot().setVisibility(View.INVISIBLE);
                        } else {
                            binding.noLocationPermission.getRoot().setVisibility(View.VISIBLE);
                        }
                    } else {
                        binding.noDevices.getRoot().setVisibility(View.GONE);
                    }
                } else {
                    binding.bluetoothOff.getRoot().setVisibility(View.VISIBLE);
                    binding.stateScanning.setVisibility(View.INVISIBLE);
                    binding.noDevices.getRoot().setVisibility(View.GONE);
                }
            } else {
                binding.noLocationPermission.getRoot().setVisibility(View.VISIBLE);
                binding.bluetoothOff.getRoot().setVisibility(View.GONE);
                binding.stateScanning.setVisibility(View.INVISIBLE);
                binding.noDevices.getRoot().setVisibility(View.GONE);

                final boolean deniedForever = Utils.isLocationPermissionDeniedForever(this);
                binding.noLocationPermission.actionGrantLocationPermission.setVisibility(deniedForever ? View.GONE : View.VISIBLE);
                binding.noLocationPermission.actionPermissionSettings.setVisibility(deniedForever ? View.VISIBLE : View.GONE);
            }
        } else {
            binding.noBluetoothPermissions.getRoot().setVisibility(View.VISIBLE);
            binding.bluetoothOff.getRoot().setVisibility(View.GONE);
            binding.stateScanning.setVisibility(View.INVISIBLE);
            binding.noDevices.getRoot().setVisibility(View.GONE);

            if(Utils.isSorAbove()){
                final boolean deniedForever = Utils.isBluetoothPermissionDeniedForever(this);
                binding.noBluetoothPermissions.actionGrantBluetoothPermission.setVisibility(deniedForever ? View.GONE : View.VISIBLE);
                binding.noLocationPermission.actionPermissionSettings.setVisibility(deniedForever ? View.VISIBLE : View.GONE);
            }

        }
    }
Start scanning for Bluetooth devices or displays a message based on the scanner state.
app/src/main/java/no/nordicsemi/android/nrfmesh/ble/ScannerActivity.java