我想我的应用程序会发出特定频率和持续时间的哔声.在相当于这个应用程序的窗口(用c#编写)中,我使用了一个带有该函数的c ++ dll
beep(frequency, duration);
Run Code Online (Sandbox Code Playgroud)
这在android中是一样的吗?或者至少如何将我的c ++ dll放入项目中?
我不想使用预先构建的mp3或系统声音,因为我想让用户选择频率和持续时间.
Eng*_*r T 82
我尝试了胺.b的答案.总之,要发出响亮的哔声:
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
Run Code Online (Sandbox Code Playgroud)
小智 14
简单的方法是使用ToneGenerator类的实例:
// send the tone to the "alarm" stream (classic beeps go there) with 50% volume
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 50);
if (val >= taux_max) {
taux_text.setTextColor(warnning_col);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); // 200 is duration in ms
}
Run Code Online (Sandbox Code Playgroud)
请参阅文档ToneGenerator以及AudioManager参数的确切含义和发电机的可能配置.
| 归档时间: |
|
| 查看次数: |
42158 次 |
| 最近记录: |