title: IllegalArgumentException: Bad stream type 21
body: <p>I got sometimes following exception on the playStore. It occures on different devices and also on different Android Versions. I never had such an error during testing and I can't produce that error. What could be the problem with the getStreamVolume? </p>
  
  <pre><code>java.lang.IllegalArgumentException: Bad stream type 21
  at android.os.Parcel.readException(Parcel.java:1326)
  at android.os.Parcel.readException(Parcel.java:1276)
  at android.media.IAudioService$Stub$Proxy.getStreamVolume(IAudioService.java:508)
  at android.media.AudioManager.getStreamVolume(AudioManager.java:487)
  at de.free.Activity.startStopService(Activity.java:452)
  at de.free.Activity.onClick(Activity.java:409)
  at android.view.View.performClick(View.java:2506)
  at android.widget.CompoundButton.performClick(CompoundButton.java:99)
  at android.view.View$PerformClick.run(View.java:9112)
  at android.os.Handler.handleCallback(Handler.java:587)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:130)
  at android.app.ActivityThread.main(ActivityThread.java:3835)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:507)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Thats the code from the Method startStopService:</p>
  
  <pre><code>private void startStopService() {
      long now = new Date().getTime();
  
      Intent i = new Intent(this, AppService.class);
  
      i.putExtra(AppService.VOLUME, volumeBar.getProgress());
      i.putExtra(AppService.RINGER, amanager.getRingerMode());
      i.putExtra(AppService.ACT_VOL, amanager.getStreamVolume(amanager.getStreamVolume(AudioManager.STREAM_RING)));
      i.putExtra(AppService.VOL_ALM, amanager.getStreamVolume(amanager.getStreamVolume(AudioManager.STREAM_ALARM)));
      i.putExtra(AppService.TIME_NOW, now);
  
      PendingIntent pi = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
      AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);   
  
      if((tb_runBG.isChecked())) {        
          alarmManager.cancel(pi);
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 *update_time, pi);    
      } else {
          alarmManager.cancel(pi);
          stopService(new Intent(this, AppService.class));    
      }
  }
  </code></pre>
  
  <p>AudioManager at onCreate:</p>
  
  <pre><code>//sets the range between 0 and the max volume
  volumeBar.setMax(amanager.getStreamMaxVolume(AudioManager.STREAM_RING));
  </code></pre>