I want to create an application that can detect incoming calls and start my custom activity after a certain number of beeps (rings), I mean after 2 or 3 or 5 beeps (rings) my activity
is triggered. How can I do it?
Thanks
I want to create an application that can detect incoming calls and start my custom activity after a certain number of beeps (rings), I mean after 2 or 3 or 5 beeps (rings) my activity
is triggered. How can I do it?
Thanks
My article about detecting incoming and outgoing calls, with the step-by-step instructions: Detecting incoming and outgoing phone calls on Android
When you detect incoming call, you can start a timer, with interval equal to beepInterval * beepCount. And launch activity on this timer.
I don't think you can count the number of rings the phone made since the start of the incoming call. There can't be a definitive measure of a single ring because the user can easily change the ringtone to a non-repetitive tune, for example, a song.
What you can do, however, is count the amount of time that passed since the arrival of the call. Set up a
BroadcastReceiver
forPHONE_STATE
(you will need the corresponding permission in the manifest to receive the event). Once you receive theEXTRA_STATE_RINGING
that came with thePHONE_STATE
, set an alarm via theAlarmManager
that will fire aService
that checks ifEXTRA_STATE_OFFHOOK
(broadcast when the call is picked up) has been broadcast after your waiting time. If not, then you can start your answering machine.I have written a quick tutorial in my website on how to catch the call's arrival (when the phone rings), when the call is picked up, and when it ends.