我希望我的应用程序具有特定的频率和持续时间。在这个应用程序的windows版本(用c#编写)中,我使用了c++动态链接库函数
beep(frequency, duration); 这在android中也是一样的吗?或者至少我该如何将我的c++动态链接库放入项目中?
我不喜欢使用预置的mp3或系统声音,因为我想让用户选择频率和持续时间。
发布于 2012-08-28 16:06:58
如果你想在安卓应用中使用你的C++代码,这是可能的。你需要看看Android NDK,它允许你在JNI (Java Native Interface)的帮助下使用execute C++代码。
Android NDK
发布于 2013-12-14 11:03:42
我试过amine.b的答案。简而言之,要播放响亮的嘟嘟声:
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); 发布于 2013-02-22 08:37:54
最简单的方法是使用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
}有关参数的确切含义和生成器的可能配置,请参阅ToneGenerator和AudioManager的文档。
https://stackoverflow.com/questions/12154940
复制相似问题