I have list of target values in ListPreference and I need to play sound when int i exceeds it (target value).
String limit = sharedPreferences.getString("limit", getString(R.string.limitdef));
switch (limit) {
case "20":
if (i >= 20) {
this.lets_dance();
} else {
if (ringtone.isPlaying()) {
ringtone.stop();
}
}
break;
case "30":
if (i >= 30) {
this.lets_dance();
} else {
if (ringtone.isPlaying()) {
ringtone.stop();
}
}
break;
}
void lets_dance:
private void lets_dance() {
if (!ringtone.isPlaying()) {
ringtone.play();
}
}
And now my problem: for example when I start the app and target value is "20", but then I change my mind and cahnge it to "30", ringtone still starts playing when int i is >=20.