title: Android BroadcastReceiver makes app crash when app is not working
body: <p>I have a Radio application that uses a Service for media player and a BroadcastReceiver to check for incoming and outgoing calls to stop or restart the media player service, it works but when I quit my app the BroadcastReceiver is still checking for calls and it crashes my application even that is gone (it has been finish) here is the code</p>
  
  <p>Manifest</p>
  
  <pre><code>&lt;service android:name=".PlayerService" 
              android:label="@string/app_name"&gt; 
              &lt;intent-filter&gt;
          &lt;/intent-filter&gt;    
      &lt;/service&gt;
      &lt;receiver android:name=".IncomingCallInterceptor"&gt;                     
          &lt;intent-filter&gt;                                                   
               &lt;action android:name="android.intent.action.PHONE_STATE"/&gt; 
               &lt;action android:name="android.intent.action.NEW_OUTGOING_CALL" /&gt;  
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>the BroadcastReceiver</p>
  
  <pre><code>import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.telephony.TelephonyManager;
  
  public class IncomingCallInterceptor extends BroadcastReceiver {                                  
  
  @Override
  public void onReceive(Context context, Intent intent) {                                         
      String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);  
  
  
      if (PlayerService.getInstance() != null) {
      if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {  
              PlayerService.getInstance().stopMusic();
      }
      if (TelephonyManager.EXTRA_STATE_OFFHOOK.equals(state)) { 
              PlayerService.getInstance().stopMusic();
      }
      if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {  
              PlayerService.getInstance().startMusic();
      }
  
      }else{}
  
  }
  
  }
  </code></pre>
  
  <p>How can I make it stop?</p>