public static boolean isLocationEnabled(final Context context) {
        if (isWithinMarshmallowAndR()) {
            int locationMode = Settings.Secure.LOCATION_MODE_OFF;
            try {
                locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
            } catch (final Settings.SettingNotFoundException e) {
                // do nothing
            }
            return locationMode != Settings.Secure.LOCATION_MODE_OFF;
        }
        return true;
    }
On some devices running Android Marshmallow or newer location services must be enabled in order to scan for Bluetooth LE devices.
This method returns whether the Location has been enabled or not.

@return true on Android 6.0+ if location mode is different than LOCATION_MODE_OFF. It always returns true on Android versions prior to Marshmallow.
app/src/main/java/no/nordicsemi/android/nrfmesh/utils/Utils.java