简体   繁体   中英

DTMF receiving in Android

my main goal is to get DTMF tones in my Android app and perform related actions. I've seen that TelephonyManager can send DTMF but there is no method to receive them . I came across many pages (most of them quite old) which suggest the use of FFT libraries through buffering the VOICE_DOWNLINK audio stream with AudioRecorder (setting proper permissions in the manifest). I tried both with AudioRecorder and MediaRecorder (which is mainly intended for creating file) as well as "Visulizer" class which contains a proper getFft methos out of the box but none of them can access MediaRecorder.AudioSource.VOICE_DOWNLINK & co even if permissions are correctly managed and granted.

uses-permission android:name="android.permission.RECORD_AUDIO"

None of the Visualizer/MediaRecorder/AudioRecorder get initialized and I'm getting frustrated by the fact that I'm chasing after record permissions in order to listen for DTMF tones. Is there any other way I'm not considering?

After many research it appears impossible since

  1. There is no DTMF listen method (Google... why??)
  2. There are limitation accessing other's phone audio to FFT. Especially related to this last point I've seen that basically all app based on a common used Google/GitHub code ( https://github.com/pjasiun/dtmf-decoder ) crashes from a certain SDK during calls. They all work fine with phone mic which is useless for phonecalls

Leaving this post for other people. For my purposes I resolved with an Arduino DTMF recognizer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM