title: TelephonyManager deprecated listen() CALL_STATE_RINGING on android 12
body: <p>I'd like to listen if there's a phone call happening while my app is in the foreground.</p>
  <p>It was like this before but now listen() is deprecated:</p>
  <pre><code>val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
              tm.listen(object : PhoneStateListener() {
                  override fun onCallStateChanged(state: Int, phoneNumber: String?) {
                      super.onCallStateChanged(state, phoneNumber)
                      when (state) {
                          TelephonyManager.CALL_STATE_RINGING -&gt; transcribingAudioConsumer.stopTranscription(null)
                          else -&gt; {}
                      }
                  }
              }, PhoneStateListener.LISTEN_CALL_STATE)
  </code></pre>
  <p>I tried something like this but I couldn't find the correct way to implement it.</p>
  <pre><code>         if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.S) {
                          tm.registerTelephonyCallback({ it.run() }, MyPhoneStateListener())
                      }
  </code></pre>
  <pre><code>  @RequiresApi(Build.VERSION_CODES.S)
      class MyPhoneStateListener : TelephonyCallback(), TelephonyCallback.CallStateListener {
          override fun onCallStateChanged(state: Int) {
              when (state) {
                  TelephonyManager.CALL_STATE_RINGING -&gt; {
                      Timber.e(&quot;omg RING&quot;)
                  }
  
                  TelephonyManager.CALL_STATE_OFFHOOK -&gt; {
                      Timber.e(&quot;omg hook&quot;)
                  }
                  TelephonyManager.CALL_STATE_IDLE -&gt; {
                      Timber.e(&quot;omg idle&quot;)
                  }
              }
          }
      }
  </code></pre>