Here is what I am doing and still not getting consistency with the mute.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Video
mVid = (VideoView) findViewById(R.id.videoview);
mVid.setOnTouchListener(this);
//mVid.setOnClickListener(this);
// Audio mgr
mAm = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
// Restore preferences
SharedPreferences sp = getSharedPreferences(ACCUWX.Preferences.ALL, MODE_PRIVATE);
mIsMute = sp.getBoolean(ACCUWX.Preferences.STORED_VOLUME, false);
mAm.setStreamMute(AudioManager.STREAM_MUSIC, mIsMute);
Log.d(DEB_TAG, "!@#!@#!In onCreate value of mIsMute is " + mIsMute);
//isMute();
//start
init();
}
public void isMute() {
SharedPreferences settings = getSharedPreferences(ACCUWX.Preferences.ALL, MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
if(mIsMute){
mAm.setStreamMute(AudioManager.STREAM_MUSIC, false);
mIsMute = false;
editor.putBoolean(ACCUWX.Preferences.STORED_VOLUME, mIsMute);
}else{
mAm.setStreamMute(AudioManager.STREAM_MUSIC, true);
mIsMute = true;
editor.putBoolean(ACCUWX.Preferences.STORED_VOLUME, mIsMute);
}
// Commit the edits!
Log.d(DEB_TAG, "Inside isMute value of mIsMute" + mIsMute);
editor.commit();
}
This is where I determine which menu button the user is selecting and the action that goes with it.
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
// Mute
case R.id.main_menu_mute:
isMute();
break;
.........
.........
.........
}
return super.onOptionsItemSelected(item);
}
Here is some of my logCat lines...this is when I ended my app in mute mode. It begins correctly, but then when I try to unmute, the correct value is stored, but I get no sound.
07-08 11:51:08.754: DEBUG/WordWeather(2984): !@#!@#!In onCreate value of mIsMute is true
07-08 11:51:26.942: WARN/AudioService(1015): stream was not muted by this client
07-08 11:51:26.950: ERROR/AudioService(1015): Could not get client death handler for stream: 3
07-08 11:51:26.950: DEBUG/WordWeather(2984): Inside isMute value of mIsMutefalse
07-08 11:51:26.997: WARN/InputManagerService(1015): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@446f0100