public void playSound() {
    AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    float actualVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    float maxVolume = (float) audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    float volume = actualVolume / maxVolume;

    int soundIdxToPlay;
    try {
      soundIdxToPlay = RandomnessProvider.getLocalRandomness().nextInt(3);
      if (soundsLoaded.contains(new Integer(soundIDs[soundIdxToPlay]))) {
        soundPool.play(soundIDs[soundIdxToPlay], volume, volume, 1, 0, 1f);
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    if (DiceProvider.getInstance() == null) {
      DiceProvider.init();
    }

    if (soundsLoaded == null) {
      soundsLoaded = new HashSet<Integer>();
      setupSound();
    }

    setPreferences();

    RandomnessProvider.init(this);

    if (getResources().getBoolean(R.bool.portrait_only)) {
      Log.v(getClass().getCanonicalName(), "portrait only");
      //noinspection ResourceType
      setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
    }

    if (getResources().getBoolean(R.bool.show_tabs)) {

      // then the main.xml for the phones is loaded with the tabhost-layout
      Log.v(getClass().getCanonicalName(), "layout for phones (tabs)");
      setupPhoneLayout(
          getResources().getString(R.string.items_attack),
          getResources().getString(R.string.items_defense),
          getResources().getString(R.string.items_hero));

      setupShakeDetection();

    } else {

      // otherwise the main.xml for tablets is loaded - portrait or landscape.
      // fragments must be set programmatically, otherwise handling orientation myself won't work

      Log.v(getClass().getCanonicalName(), "layout for tablets (three-list)");

      FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

      fragmentTransaction.add(
          R.id.category_attack_container,
          new CategoryList(),
          getResources().getString(R.string.items_attack));

      fragmentTransaction.add(
          R.id.category_defense_container,
          new CategoryList(),
          getResources().getString(R.string.items_defense));

      fragmentTransaction.add(
          R.id.category_hero_container,
          new HeroList(),
          getResources().getString(R.string.items_hero));

      // "can not perform this action after onSaveInstanceState" => commit() ->
      // commitAllowingStateLoss()
      fragmentTransaction.commitAllowingStateLoss();
    }
  }