sdm660-common: DeviceSettings: Fix Clear Speaker IllegalStateException
* trace: E AndroidRuntime: java.lang.IllegalStateException E AndroidRuntime: at android.media.MediaPlayer._stop(Native Method) E AndroidRuntime: at android.media.MediaPlayer.stop(MediaPlayer.java:1397) * also do small refactoring while at it Former-commit-id: 98f1335384a6b534becf87ad54333f737de9e15e Signed-off-by: Joey Huab <joey@evolution-x.org>
This commit is contained in:
parent
7b224410e5
commit
dbb6cddf41
1 changed files with 7 additions and 4 deletions
|
@ -77,8 +77,8 @@ public class ClearSpeakerFragment extends PreferenceFragment implements
|
|||
|
||||
@Override
|
||||
public void onStop() {
|
||||
stopPlaying();
|
||||
super.onStop();
|
||||
stopPlaying();
|
||||
}
|
||||
|
||||
public boolean startPlaying() {
|
||||
|
@ -107,9 +107,12 @@ public class ClearSpeakerFragment extends PreferenceFragment implements
|
|||
|
||||
public void stopPlaying() {
|
||||
if (mMediaPlayer != null) {
|
||||
mMediaPlayer.stop();
|
||||
mMediaPlayer.reset();
|
||||
mMediaPlayer.release();
|
||||
if (mMediaPlayer.isPlaying()) {
|
||||
mMediaPlayer.stop();
|
||||
mMediaPlayer.reset();
|
||||
mMediaPlayer.release();
|
||||
mMediaPlayer=null;
|
||||
}
|
||||
}
|
||||
mAudioManager.setParameters("status_earpiece_clean=off");
|
||||
mClearSpeakerPref.setEnabled(true);
|
||||
|
|
Loading…
Reference in a new issue