Easily set and customize ringtones, notification sounds, and alarms programmatically on Android using Kotlin.
Supports setting ringtones globally or per contact from assets or local files (URIs) — all without boilerplate code.
Perfect for Android developers who need a simple, flexible ringtone manager and setter library written entirely in Kotlin.
- Simplified API for setting system and contact ringtones without needing to pass Context or Activity.
- Supports multiple ringtone sources, including assets, local storage (URI), and remote URLs.
- Easy assignment of ringtones to specific contacts via different contact identifiers (ID, URI, phone number).
- Asynchronous operations with success and error callbacks for better control.
- Supports setting different types of system ringtones: call, notification, and alarm.
- Fully written in Kotlin with idiomatic usage and extension-friendly design.
Add the following dependency to your build.gradle or build.gradle.kts file:
| Set System Ringtone | - android.permission.WRITE_SETTINGS - android.permission.READ_EXTERNAL_STORAGE (API ≤ 32) - android.permission.WRITE_EXTERNAL_STORAGE (API ≤ 32) |
Required to change system ringtone and access local files (on older Android versions). |
| Set Contact Ringtone | - android.permission.READ_CONTACTS - android.permission.WRITE_CONTACTS - android.permission.READ_EXTERNAL_STORAGE (API ≤ 32) - android.permission.WRITE_EXTERNAL_STORAGE (API ≤ 32) |
Required to update contact ringtones and access files from storage. |
| Interactive Contact Picker | - android.permission.READ_CONTACTS - android.permission.WRITE_CONTACTS |
Required for selecting and modifying contact info interactively. |
Use one of these methods to set ringtones:
ℹ️ Important: onSuccess for system ringtones is onSuccess { } — it takes no arguments.
ℹ️ Important: onSuccess(block: (ContactInfo) -> Unit) returns contact details for contact ringtones only.
You can load ringtones from different types of sources:
⚠️ About asset file paths You can use any of these path styles for assets:
Internally, RingtoneHelper will normalize these paths, so feel free to use whichever style you prefer. ✅ Recommendation: Use ringtones/my_ringtone.mp3 for a concise path.
| onSuccess | Ringtone is successfully set. Either provides ContactInfo if a contact target or no arguments for system ringtones. |
| onFailure | An error occurs. Provides a Throwable for debugging. |
| onDone | Operation finishes (either success or failure). |
If you have suggestions, questions, or feedback, feel free to reach out:
- Open an issue on GitHub
- Contact me directly via GitHub Profile
- Or send an email to: [email protected]
This library is available via:
📦 Maven Central:
Easy integration using Gradle/Maven.
🐙 GitHub Packages: Published to
the GitHub repository packages as an alternative.
- 💻 GitHub Repository: Source code, examples, and documentation are available here: https://github.com/AmjdAlhashede/RingtoneSmartKit
💭 Enjoy!
Feel free to contribute or open issues if you have suggestions or encounter problems. Happy coding! 🎵
Copyright 2025 Amjd Alhashede
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.png)


