捕获 SDK 设置蜂鸣声和振动属性



需要使用捕获SDK了解哔哔声和振动设置背后的正确设置。将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()));
}
}
}
};

我终于想通了...去查看旧代码,意识到我使用了错误的配置 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");
}
}

最新更新