android: Unchecking Checkbox on the fly (state checked=true)
<p>I've read several topics to this but couldn't find any good solution for my problem.</p>

<p>I've one Checkbox which is standard "checked" with state TRUE. I want know to stop my background music if I'm unchecking it - On the fly with no button. <strong>I know that there is something missing but I cant get it! Thanks for ur help!</strong></p>

<p><strong>I'm using this Code which has no errors but it doesn't works correctly.</strong> </p>

<pre><code>private CheckBox chkBoxMusic;
private MediaPlayer mp_music;
OnClickListener checkboxListener;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.sound);
    mp_music = MediaPlayer.create(this,R.raw.menusong);


    chkBoxMusic = (CheckBox) findViewById(R.id.checkBoxMusic);

    checkboxListener = new OnClickListener() {
         public void onClick(View v) {

            boolean checked = ((CheckBox) v).isChecked();

               if (!checked) {

                   mp_music.stop();
               }     
            }
    };

   chkBoxMusic.setOnClickListener(checkboxListener);

   }

}
</code></pre>
