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

Target sdk version 30 doesn't allow to change the ringtone. #6

Closed
ShashankSMayya opened this issue Mar 25, 2021 · 2 comments
Closed

Comments

@ShashankSMayya
Copy link

I have an app which has target sdk of 30 and I tried using the package to set the ringtone, it doesn't work. It gives error of "java.lang.IllegalArgumentException: Unsupported MIME type audio/mp3" . I did try setting target sdk to 28 as your file had the same one and it does seem working.

Error I get in detail:

E/MethodChannel#ringtone_set(15044): Failed to handle method call
E/MethodChannel#ringtone_set(15044): java.lang.IllegalArgumentException: Unsupported MIME type audio/mp3
E/MethodChannel#ringtone_set(15044): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
E/MethodChannel#ringtone_set(15044): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
E/MethodChannel#ringtone_set(15044): at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
E/MethodChannel#ringtone_set(15044): at android.content.ContentResolver.insert(ContentResolver.java:2149)
E/MethodChannel#ringtone_set(15044): at android.content.ContentResolver.insert(ContentResolver.java:2111)
E/MethodChannel#ringtone_set(15044): at acr.rt.ringtone_set.RingtoneSetPlugin.setThings(RingtoneSetPlugin.java:107)
E/MethodChannel#ringtone_set(15044): at acr.rt.ringtone_set.RingtoneSetPlugin.onMethodCall(RingtoneSetPlugin.java:145)
E/MethodChannel#ringtone_set(15044): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#ringtone_set(15044): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#ringtone_set(15044): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#ringtone_set(15044): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#ringtone_set(15044): at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#ringtone_set(15044): at android.os.Looper.loop(Looper.java:183)
E/MethodChannel#ringtone_set(15044): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#ringtone_set(15044): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#ringtone_set(15044): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#ringtone_set(15044): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@ShashankSMayya
Copy link
Author

Hey,
I found the solution for the above issue.
Weirdly target api 30 doesn't take MIME type as "audio/mp3". I edited the Java file and changed the MIME type to "audio/mpeg".
It seems to work perfectly.
The changed code is here. I guess you can update it to new verison with this changes so that it can support API 30.
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg");

Thanks for the package.

@rtacr
Copy link
Owner

rtacr commented Apr 1, 2021

Hi, Thanks for your contribution.

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

No branches or pull requests

2 participants