Search code examples
androidsocketmobilecapture-sdk

Capture SDK set beep and vibrate properties


Need to understand the proper settings behind the BEEP and VIBRATE settings using the Capture SDK. When setting the DEVICE_RUMBLE_CONFIG to 1 or 0 it seems I get an error and nothing is changed. Same issue with DEVICE_SOUND_CONFIG.

if (getBRSharedPreferenceBoolean(PreferencesActivity.PREF_SOCKET_SCANNER_VIBRATE, false)) {
  mDevice.setProperty(Property.create(Property.DEVICE_RUMBLE_CONFIG,1), propertyCallback);
} else {
  mDevice.setProperty(Property.create(Property.DEVICE_RUMBLE_CONFIG,0), propertyCallback);
}

if (getBRSharedPreferenceBoolean(PreferencesActivity.PREF_SOCKET_SCANNER_BEEP, false)) {
  mDevice.setProperty(Property.create(Property.DEVICE_SOUND_CONFIG,1), propertyCallback);
} else {
  mDevice.setProperty(Property.create(Property.DEVICE_SOUND_CONFIG,0), propertyCallback);
}

PropertyCallback propertyCallback = new PropertyCallback() {
        @Override
        public void onComplete(@Nullable CaptureError captureError, @Nullable Property property) {
            if (captureError != null) {
                Log.d("onComplete", String.format("capture error %s", captureError.getMessage()));
            } else {
                if (property != null) {
                    Log.d("onComplete", String.format("property set %d", property.getId()));
                }
            }
        }
    };


Solution

  • I finally figured it out...went to look at the old code and realized I was using the wrong configuration ID's. Here are the right ones...One additional note about the code below is that I'm including FLASH in the beep and vibrate option by selecting ACTION_ALL.

    if (deviceClient != null) {
    
                if (beep && vibrate) {
                    Property property = Property.create(Property.DEVICE_LOCAL_DECODE_ACTION, LocalDecode.ACTION_ALL);
                    deviceClient.setProperty(property, p);
                    Log.d("configureSocket", "RUMBLE and BEEP");
                } else if (beep) {
                    Property property = Property.create(Property.DEVICE_LOCAL_DECODE_ACTION, LocalDecode.ACTION_BEEP);
                    deviceClient.setProperty(property, p);
                    Log.d("configureSocket", "BEEP");
                } else if (vibrate) {
                    Property property = Property.create(Property.DEVICE_LOCAL_DECODE_ACTION, LocalDecode.ACTION_RUMBLE);
                    deviceClient.setProperty(property, p);
                    Log.d("configureSocket", "RUMBLE");
                } else {
                    Property property = Property.create(Property.DEVICE_LOCAL_DECODE_ACTION, LocalDecode.ACTION_NONE);
                    deviceClient.setProperty(property, p);
                    Log.d("configureSocket", "NO BEEP OR RUMBLE");
                }
            }