Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberFormatException in RingtonePreferenceDialogFragmentCompat #203

Open
adrcotfas opened this issue Oct 24, 2019 · 7 comments
Open

NumberFormatException in RingtonePreferenceDialogFragmentCompat #203

adrcotfas opened this issue Oct 24, 2019 · 7 comments
Labels

Comments

@adrcotfas
Copy link

Hello,
I'm getting this exception on a Pixel 3.

java.lang.NumberFormatException: 
 at java.lang.Long.parseLong (Long.java:594)
 at java.lang.Long.parseLong (Long.java:636)
 at android.content.ContentUris.parseId (ContentUris.java:89)
 at android.media.RingtoneManager.getRingtonePosition (RingtoneManager.java:513)
 at com.takisoft.preferencex.RingtonePreferenceDialogFragmentCompat.a (RingtonePreferenceDialogFragmentCompat.java:146)
 at com.takisoft.preferencex.RingtonePreferenceDialogFragmentCompat.a (RingtonePreferenceDialogFragmentCompat.java:11)
 at androidx.preference.PreferenceDialogFragmentCompat.a (PreferenceDialogFragmentCompat.java:50)
 at com.takisoft.preferencex.RingtonePreferenceDialogFragmentCompat.access$000 (RingtonePreferenceDialogFragmentCompat.java)
 or                     .access$002 (RingtonePreferenceDialogFragmentCompat.java)
 or                     .access$202 (RingtonePreferenceDialogFragmentCompat.java)
 or                     .access$600 (RingtonePreferenceDialogFragmentCompat.java)
 or                     .access$700 (RingtonePreferenceDialogFragmentCompat.java)
 or                     .addCustomExternalRingtone (RingtonePreferenceDialogFragmentCompat.java)
 or                     .buildAdapter (RingtonePreferenceDialogFragmentCompat.java)
 or                     .buildUniqueFile (RingtonePreferenceDialogFragmentCompat.java)
 or                     .createCursor (RingtonePreferenceDialogFragmentCompat.java)
 or                     .getFileDisplayNameFromUri (RingtonePreferenceDialogFragmentCompat.java)
 or                     .getUniqueExternalFile (RingtonePreferenceDialogFragmentCompat.java)
 or                     .newInstance (RingtonePreferenceDialogFragmentCompat.java)
 or                     .onCreateDialog (RingtonePreferenceDialogFragmentCompat.java)
 or                     .onDialogClosed (RingtonePreferenceDialogFragmentCompat.java)
 or                     .onPrepareDialogBuilder (RingtonePreferenceDialogFragmentCompat.java)
 or                     .splitFileName (RingtonePreferenceDialogFragmentCompat.java)
@gregkorossy
Copy link
Owner

What Android version do you use?

@adrcotfas
Copy link
Author

@Gericop: Android 10
I see this problem on other generations of Pixel and OnePlus 7 Pro too (ANRs & crashes report from Google Play Console).

@gregkorossy
Copy link
Owner

Do those devices run Android 10 as well?

@adrcotfas
Copy link
Author

@Gericop: Yes, there's Android 10 on all of them.

@gregkorossy
Copy link
Owner

Well, at first look it must be something with the scoped storage introduced in 10. The problem is to add a custom ringtone, the app must copy the file from wherever the user selects it from to the ringtone folder of the phone but it seems like there's no way to do this with scoped storage. A workaround would be to show a save dialog after selecting the file and saving it to the ringtone folder but that's just a pretty terrible UX...
Still looking into a proper fix though.

@gregkorossy
Copy link
Owner

A different solution would be introducing the shared prefs to the game so the custom ringtones would get copied into the app folders (which are available with scoped storage), and the custom ringtone's properties would be saved to the shared prefs.

I wonder how the file explorers will work with the messy scoped storage... I guess they won't.

@adrcotfas
Copy link
Author

adrcotfas commented Apr 21, 2020

@Gericop do you know where the list of added custom notification sounds is stored?
I would like to clear it in the following case:

  • user adds custom notification sounds (on a pre-Android 10 device)
  • user updates to Android 10
  • user tries to change the notification sound, it fails with NumberFormatException. I would like to catch this and clear the custom sounds.

I see that if you start fresh with Android 10, a toast is shown when trying to add a custom ringtone which is still better than a completely unusable RingtonePreference like the case above.

Edit: the exception I'm getting comes from onPrepareDialogBuilder where createCursor is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants