title: Intercepting incoming calls on Android
body: <p>I would like to write software for my Android phone that intercepts incoming calls and plays a short audio clip instructing the caller to press "1" to proceed with the call. This is for fighting telemarketers.</p>
  
  <p><strong>Is this possible with the current (Android 7 "Nougat") API?</strong></p>
  
  <p>Notes: </p>
  
  <ul>
  <li><p>It's hard to get a clear answer because in 2012, Android 2.3 (Gingerbread) removed some vital API related to modifying the phone state, see <a href="https://stackoverflow.com/questions/11180727/how-to-intercept-incoming-calls-android-2-3-x">here</a>. However, Android 7 ("Nougat") seems to support call-blocking (see <a href="https://stackoverflow.com/questions/1083527/how-to-block-calls-in-android/35912862#35912862">here</a>), so I'm hopeful that the current API supports intercepting calls.</p></li>
  <li><p>I don't want to forward calls to some server as suggested <a href="https://stackoverflow.com/questions/32448809/is-it-possible-to-intercept-an-incoming-call-via-an-app-ios-and-android">here</a>.</p></li>
  <li><p>I would prefer to write the software myself, and not install an app like Hiya.</p></li>
  <li><p>I have a regular phone number assigned by my carrier (no fancy Google Voice or VOIP stuff), and I use the standard "Phone" app. </p></li>
  <li><p>My phone is not rooted.</p></li>
  <li><p>This is inspired by the <a href="http://www.jollyrogertelco.com/" rel="nofollow noreferrer">Jolly Roger Telephone Company</a> anti-telemarketer bot.</p></li>
  <li><p>I previously asked a similar question for iPhones <a href="https://stackoverflow.com/questions/42144316/intercepting-incoming-calls-on-iphone">here</a>.</p></li>
  </ul>
  
  <p>Thanks.</p>