title: Listening for phone code not executing?
body: <p>My app plays audio, and so I want to mute my app's audio when the user gets a call. That way the music won't be playing over the users call. I have used <code>phoneStateListener</code> , but for some reason the methods in it aren't executing-I know because the logs aren't displaying:</p>
  
  <pre><code>PhoneStateListener phoneStateListener = new PhoneStateListener() {
          @Override
          public void onCallStateChanged(int state, String incomingNumber) {
              if (state == TelephonyManager.CALL_STATE_RINGING) {
                  //Incoming call: Pause music
                    TwentySeconds.stopTimer(); //Stop service which mutes app
             Intent i = new Intent(BaseActivity.this, Main_Menu.class);
              startActivity(i);
  
                  Toast.makeText(BaseActivity.this, "INCOMING CALL", Toast.LENGTH_SHORT).show();
                  Log.v(TAG, "INCOMING CALL");
  
              } else if (state == TelephonyManager.CALL_STATE_IDLE) {
                  //Not in call: Play music
                  Log.v(TAG, "NOT IN A CALL");
              } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                  //A call is dialing, active or on hold
                     TwentySeconds.stopTimer(); //Stop service which mutes app
             Intent i = new Intent(BaseActivity.this, Main_Menu.class);
              startActivity(i);
  
                  Log.v(TAG, "CALL IS ACTIVE!");
                  Toast.makeText(BaseActivity.this, "DIALING", Toast.LENGTH_SHORT).show();
              }
          }
  
      };
  </code></pre>
  
  <p>I have looked all over the web to find out how to do this--One way is I found is to use the intent, but that requires extending BroadcastReceiver, and I can't extend two things. So, for now, the phoneStateListener is doing absolutely nothing. I really appreciate all of your help in fixing my <code>PhoneStateListener</code>.</p>
  
  <p>Thanks,
  Rich</p>