title: onPause() without intent , onResume() without onCreate()
body: <p>I'm building an app that plays music on the background with service. The music is muted when the user is not in the app and unmuted when he is back. I used the <code>onPause()</code> and <code>onResume()</code> methods to do this.</p>
  
  <p>The problem is - every time the user enters a new activity, the music pauses for a second and then resumes, because for a second the current activity is paused. 
  another problem - for the first run of the activity, the <code>onResume()</code> and <code>onCreate()</code> both works, which makes my service stops from the <code>onResume()</code> without it even being created from the <code>onCreate()</code> (which makes the app shut down).
  is there a way to use <code>onPause()</code> without the intent part (or another similar way?)</p>
  
  <p>is there a way to use <code>onCreate()</code> without to <code>onResume()</code> on the first run?</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      counter++;
  
      if (counter==1) {
          alliesSPEditor.putBoolean("isAllies", true);
          alliesSPEditor.commit();
          startService(new Intent(this,MusicService.class));
      }
  
  @Override
  protected void onPause() {
      super.onPause();
      MusicService.getMP().mute();
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      if (counter!=1) //because the counter is still 1, the app won't shut down this way but it will not unmute the music.
      MusicService.getMP().unMute();
  
  }
  </code></pre>