android - 捕获 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()));
}
}
}
};
解决方案
我终于想通了...去看旧代码并意识到我使用了错误的配置 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");
}
}
推荐阅读
- javascript - Jquery 函数应该适用于子类,而不是适用于所有类
- swift - 如何在 SwiftUI 中实现函数?
- javascript - 使用字典中的值对字符串进行编码
- google-assistant-sdk - 我想在谷歌助手上创建一个动作来使用谷歌主页控制智能灯泡
- tableau-api - Tableau 性别信息图表视觉
- c# - EF Core 2.2 新迁移不断删除和重新创建种子数据
- django-rest-framework - 如何使用 DRF 的 JWT 身份验证对存储在文件中的用户进行身份验证
- azure - 到 S2S 网络的 Azure P2S 客户端流量
- javascript - 如何制作一个 chrome 扩展,其表单即使在关闭/打开扩展后仍保持填充状态?
- html - 导航菜单和页脚不固定