首页 > 解决方案 > 捕获 SDK 设置哔声和振动属性

问题描述

需要了解使用 Capture SDK 的 BEEP 和 VIBRATE 设置背后的正确设置。将 DEVICE_RUMBLE_CONFIG 设置为 1 或 0 时,似乎我收到了一个错误,并且没有任何更改。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()));
                }
            }
        }
    };

标签: androidsocketmobilecapture-sdk

解决方案


我终于想通了...去看旧代码并意识到我使用了错误的配置 ID。这是正确的...关于以下代码的另一个注意事项是,我通过选择 ACTION_ALL 在哔声和振动选项中包含了 FLASH。

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");
            }
        }


推荐阅读