Being new to Android development I have been researching StackOverflow for an answer to this question: How to mute the phone ringer for all incoming messages and calls when I am supposed to be in a Meeting as indicated by my Calendar. I am able to access the calendar and able to check if present time is within the times set for an event. But how do I send any incoming phone calls to voice mail (and send a text message to caller). I have gone through lots of questions here:
"How to detect incoming calls, in an Android device?"
"Incoming call broadcast receiver not working (Android 4.1)"
"How to detect incoming call with the help of Broadcast Receiver?"
"Custom incoming/outgoing call screen in Android"
"how to make an incoming call from our application"
"Android: Taking complete control of phone(kiosk mode), is it possible? How?"
"How to disconnect incoming call in android by programatically"
The ITelephony using AIDL looked promising untill I found out that it no longer works under Android 4.2 etc due to security issues.
At the moment the answer: "How to detect incoming calls, in an Android device?" seems to be better simply because it seems to handle incoming calls in an elegant way - but the answer does not talk about how to (a) Silence the Ringer, (b) End the Call/Divert it etc - the example explains how to determine what state the phone is in at any given time. The other drawback seems to be I am struggling to unregister the listener function which means even after the example app has been terminated, the listener still seems to remain active and jumps into action whenever there is a call. Only way to stop that seems to be to restart the phone - which is very annoying.
The other aspect is that most of these questions are a year or more old and some of the old answers are no longer valid - as I mentioned earlier - the ITelephony looked promising but no longer works with new phones.
The Google documentation seems to suggest that a program can programmatically wrap up an answer to an incoming call in a SMS Text message by sending an Intent etc - but no examples anywhere and looks like the Google's documentation may be out of date (or I am reading an old version of it on the internet - though don't know how it is possible since I am using Google Search to find an answer.)