Preferences updates just once
<p>I've made a small app with a main activity and a preference activity. This is the PrefsActivity:</p>

<pre><code>public class PrefsActivity extends PreferenceActivity {

@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);
    }
}
</code></pre>

<p>Then I trigger the Preference activity from the main activity via menu and ask to set the volume to 0 if the checkbox is selected:</p>

<p>This is the whole main activity:</p>

<pre><code>package com.stressedmanasoft.clickcounter;

import android.os.Bundle;
import android.app.Activity;
import android.view.*;
import android.widget.*;
import android.graphics.*;
import android.media.*;
import android.content.*;
import android.preference.*;

public class MainActivity extends Activity {

ImageView counter;
MediaPlayer clicksnd;
MediaPlayer resetsnd;
int x=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    counter = (ImageView) findViewById(R.id.Counter);
    clicksnd = MediaPlayer.create(this, R.raw.clicksnd);
    resetsnd = MediaPlayer.create(this, R.raw.resetsnd);

    final TextView count = (TextView) findViewById(R.id.Count);
    Typeface face = Typeface.createFromAsset(getAssets(), "Bohemian_typewriter.ttf");
    count.setTypeface(face);
    count.setText(""+x);

    final Button countButton = (Button) findViewById(R.id.CountButton);
    countButton.setOnClickListener (new View.OnClickListener() {   
        public void onClick(View v) {
            clicksnd.start();
            x = x+1;
            count.setText(""+x);
        }
    });

    final Button resetButton = (Button) findViewById(R.id.ResetButton);
    resetButton.setOnClickListener (new View.OnClickListener() {   
        public void onClick(View v) {
            resetsnd.start();
            x = 0;
            count.setText(""+x);
        }
    });

    SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this);
    if(myPreference.getBoolean("checkBox", true)) {
        clicksnd.setVolume(0, 0);}

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    switch (item.getItemId())
    {
    case R.id.menu_settings:
        Intent intent = new Intent(MainActivity.this, PrefsActivity.class);
        startActivity(intent);
        break;
    }
    return super.onOptionsItemSelected(item);
}

@Override
protected void onResume() {
super.onResume();

SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this);
if(myPreference.getBoolean("checkBox", true)) {
    clicksnd.setVolume(0, 0);
    }

}

}
</code></pre>

<p>When I start the app, the audio is ON and the checkbox is NOT checked. If I check it, the audio turns OFF as expected, but if I uncheck it the audio remains OFF. Why?</p>

<p>Should I add a Listener?</p>

<p>Thanks in advance</p>
