title: Answer incoming call using android.telecom and InCallService
body: <p>Since API 21, Google has been adding features to <a href="https://developer.android.com/reference/android/telecom/package-summary.html" rel="noreferrer" title="android.telecom on developer.android.com">android.telecom</a> in general, especially by implementing more members of <a href="https://developer.android.com/reference/android/telecom/TelecomManager.html" rel="noreferrer" title="TelecomManager on developer.android.com">TelecomManager</a> and the addition of <a href="https://developer.android.com/reference/android/telecom/InCallService.html" rel="noreferrer" title="InCallService on developer.android.com">InCallService</a>. This last one is is supposed to allow non-system, 3rd-party apps to provide and replace the functionality of the system Calls app in-call screen - the Window that pops up and allows action on <code>EXTRA_STATE_OFFHOOK</code> or <code>EXTRA_STATE_RINGING</code> broadcasts (i.e. incoming and outgoing phone calls). </p>
  
  <p>Currently, only this screen has full control of ringing and active calls and associated system callbacks with fine-grained information, by means of the root-restricted <code>MODIFY_PHONE_STATE</code> permission and a lot of secured AOSP code not even accessible by reflection. It's notably one of the most changed pieces of code in different manufacturers' ROM flavours, together with the launcher, contacts and camera.</p>
  
  <p>This is all very pretty but...</p>
  
  <p><strong>How do you actually develop a 3rd-party InCallService?</strong></p>
  
  <p>Namely:</p>
  
  <ol>
  <li>How do you get notified about, and acquire instances of GSM Calls</li>
  <li>How does one answer these calls</li>
  <li>What is the life-cycle of the callbacks on this class</li>
  <li>Does Google provide any actual tutorial for this that I haven't found</li>
  </ol>
  
  <p>I won't ask answers for all of these at once, but any one answer probably associates to the other questions. This is broad but intrinsically it needs to be: there's no example on the web I've stumbled upon other than AOSP-code, and that code is based on the assumption of root-privileges, which makes it unusable for 3rd-party app development purposes.</p>