这是我的第一个应用,我正在尝试从传感器获取数据。
该传感器为Digiducer,根据其网站,它使用通用USB音频驱动程序。
No drivers or DLL’s required! USB Audio drivers are standard in most operating systems (iOS, Windows, MacOS, Android) LINK
我读过USB Digital Audio Article,它说如果该设备符合类要求(它声称是这样),则不需要安装任何特定的驱动程序。
The term driverless is a common synonym for class compliant, indicating that it is possible to use the standard features of such a peripheral without requiring an operating-system specific driver to be installed. LINK
我检查了Android support for USB audio class一章中提到的所有条件,并且传感器与它们完全匹配
Android 5.0 (API level 21) and above supports a subset of USB audio class 1 (UAC1) features:
- The Android device must act as host
- The audio format must be PCM (interface type I)
- The bit depth must be 16-bits, 24-bits, or 32-bits where 24 bits of useful audio data are left-justified within the most significant bits of the 32-bit word
- The sample rate must be either 48, 44.1, 32, 24, 22.05, 16, 12, 11.025, or 8 kHz
- The channel count must be 1 (mono) or 2 (stereo)
我不知道该怎么做才能从传感器获取数据。
最佳答案
我自己弄清楚了。
其实我什么也没做。
我只需要调用AudioManager并在输入设备中搜索设备名称
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adiArray = am.getDevices(1); // INPUT_DEVICES = 1
for (AudioDeviceInfo deviceInfo : adiArray) {
String name = deviceInfo.getProductName().toString().toLowerCase();
if (name.contains("33d01")) {
externalMic = deviceInfo;
break;
}
}
关于android - 我如何从假装成微型电话的USB加速度传感器获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58979003/