WhereYouGo icon indicating copy to clipboard operation
WhereYouGo copied to clipboard

cannot pass a negative number to `startActivtyForResult`

Open bekuno opened this issue 4 years ago • 0 comments

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

bekuno avatar Jan 22 '21 18:01 bekuno