• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Answering a call.

I want to be able to answer the phone by blowing into the mic, so that I can keep my hands on the handles while riding my bike and a call comes in. Surely this has to be one of the easiest apps to write (no more than a few lines of code), I just need to know which is the phone-class, then I can use e.g. call.answer(). (I think I'm already making some headway in finding out how to detect blowing into the mic - or making any random noise for that matter)

Edit:
android.telephony.TelephonyManager seems not to be exactly what I want: it's a monitoring-class, which tells you if the phone's ringing, or offhook (My Hero is deficient here; no hooks anywhere; should I've nought some as after-market?). What I want is:
If mic.blowingsound==true
{ phone.pickup(); }
Maybe also verify if
TelephonyManager=CALL_STATE_RINGING before I set CALL_STATE_OFFHOOK=true
Pardon the bogus pseudocode pls. Sadly, set CALL_STATE_OFFHOOK=true is impossible using android.telephony.TelephonyManager.
 
Surely this has to be one of the easiest apps to write (no more than a few lines of code)

I admire your optimism, and look forward to you posting the full source code here by the end of the day. :)

Mark

p.s.
I don't expect it to be quite so easy. I haven't touched telephony stuff, but I have done some sound input processing. It wasn't as trivial as you might think.
 
Upvote 0
rrThanks fro your reply. I'm looking forward to seeing your code, if you have some to contribute. Of course, I'll make my code (and app) freely available to anyone interested.
Now I intend to make use of android.media.AudioRecord, I hope I can send the output to /dev/null so I dwon't end up with loads of sounddata that I don't intend to use, at least not until this gets converted intoa voice dialer (wher you tell the phone to "dial that stupid cow" - as in call mum in law)

I've just eralized that this app will have to sit quietly in the background until a call comes in - that might be a tad difficult to realize without constant polling.
One approach could be to use Bluetooth | Android Developers (look for this text: accept() )
 
Upvote 0
I admire your optimism, and look forward to you posting the full source code here by the end of the day. :)

Mark

p.s.
I don't expect it to be quite so easy. I haven't touched telephony stuff, but I have done some sound input processing. It wasn't as trivial as you might think.
I just need to detect if there's any level of signal input present, then discard it and answer the call, I don't have to do anything with the signal - except discard it so that it won't clutter the buffers. That can't be too difficult, now can it?
At most I'd want to have a minimum dB-level.
It'd be cool,if it were also possible to refuse a call by some other voice command: way into fantasy-terrain here, I suppose one could let a user record keyphrases
like "answer" or "refuse" the user can say anything he wants but must be consistent
throughout use of the application.

btw it's the end of the day here, and I'm typing this while lying in bed, so no source code available, I'd love to share but gave nothing to give you, man!
 
Upvote 0
Hi Dutchmarco

I wasn't seriously asking for the source code by the end of the day.
It was intended as a (hopefully!) humorous response, considering how complex I thought the task was. :)

I did some audio processing for a guitar tuner application. All that had to do was work out the frequency of the input sound.

I found it particularly tricky. And the maths required to calculate the frequency was non-trivial, and not fast. (I took about 0.5 seconds worth of audio input and it took another 0.6 seconds to do the frequency calculation.) It's not particularly reliable, and is easily defeated by background noise. There are other guitar tuner apps on the market that manage to work faster. So maybe my code is particularly crappy. Or maybe they did the calculations in C.

As you're only trying to detect a sound above a certain noise level it should be a little simpler. Background noise will still be a problem though.

As for voice commands... unless you're thinking of offloading the work to Google who do the voice processing on their servers, then I think that would be way too ambitious.

My other app on the market is a sound activated camera. So I listen for a noise above a certain threshold in order to trigger the camera. So it has something in common with what you're trying to do.

As I charge for the app, I'm probably not quite ready to publish all the code here just yet. :)
Although I might be prepared to share the sound level detection code privately. There's nothing particularly clever in it anyway.

Mark
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones