WhereYouGo
WhereYouGo copied to clipboard
cannot pass a negative number to `startActivtyForResult`
I have discovered a bug that we cannot pass a negative number to startActivtyForResult. We are doing this in the following snippet in the Directions Settings:
notificationSoundType.setOnPreferenceChangeListener((preference, o) -> {
String newValue = (String) o;
int result = Utils.parseInt(newValue);
if (result == PreferenceValues.VALUE_GUIDING_WAYPOINT_SOUND_CUSTOM_SOUND) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("audio/*");
if (!Utils.isIntentAvailable(intent)) {
intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
}
startActivityForResult(intent, R.string.pref_KEY_S_GUIDING_WAYPOINT_SOUND);
} else {
Preferences.GUIDING_WAYPOINT_SOUND = result;
}
return true;
});
I'll fix it right away in an own commit.
Source: https://stackoverflow.com/a/25529974
Originally posted by @SchoolGuy in https://github.com/cgeo/WhereYouGo/issues/240#issuecomment-765509739