Android Simple Mute Media Volume, but crashes button then app...?
<p>I'm attempting to mute media volume, which seems to work but when button that controls mute on/off is pressed it crashes.</p>

<p>Here is my code:</p>

<pre><code>SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
                boolean cmute = getPrefs.getBoolean("mute", false);

                if (cmute == false){
                    // mMediaPlayer.setVolume(0,0); &lt;-- this causes crash of button/app, but works until then muting media volume =/                
                    Editor editor = getPrefs.edit();
                    editor.putBoolean("mute", true);
                    editor.commit();
                    Editor editor2 = getPrefs.edit();
                    editor.putBoolean("notice", true);
                    editor.commit();
                    SharedPreferences getPrefs2 = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
                    View btn = findViewById(R.id.mute);
                    btn.setBackgroundResource(R.drawable.sound);

                }
</code></pre>

<p>So, i need simple line i can have within the IF statement of this boolean that mutes media volume and does not crash button.</p>

<p>Many thanks.</p>
