This tutorial shows how to open the system ringtone picker and retrieve the selected ringtone URI using ActivityStarter.
What This Does
- Opens the native Android ringtone picker
- Lets the user choose a ringtone
- Returns the selected ringtone URI (e.g.
content://media/internal/audio/media/27) - Displays or stores the URI for later use
This does not automatically set the ringtone. Android does not allow that via intent.
(You’ll need an extension like Taifun Settings for that.)
Components Needed
From Connectivity:
ActivityStarter
From User Interface:
ButtonNotifier(orLabel)
Step 1: Configure the Ringtone Picker Intent
In Button.Click, configure ActivityStarter like this:
Action
android.intent.action.RINGTONE_PICKER
Extras (dictionary)
| Key | Value |
|---|---|
android.intent.extra.ringtone.TYPE |
1 |
android.intent.extra.ringtone.TITLE |
"Select ringtone" |
Ringtone type values:
1= Ringtone2= Notification4= Alarm
Then call:
ActivityStarter.StartActivity
Step 2: Handle the Result
Android returns the selected ringtone in:
android.intent.extra.ringtone.PICKED_URI
This comes back in ActivityStarter.AfterActivity as a text string.
Example returned text
android.intent.extra.ringtone.PICKED_URI=content://media/internal/audio/media/27
Step 3: Extract the Picked URI
In:
when ActivityStarter.AfterActivity (result)
Use text processing to remove the key name and keep the URI.
Logic
-
Replace:
android.intent.extra.ringtone.PICKED_URI=with:
(empty string)
Store the result in a global variable, for example:
global ringtone
Step 4: Display or Save the URI
You can now:
- Show it using
Notifier.ShowAlert - Display it in a
Label - Save it to
TinyDB - Pass it to a settings extension later
Example output
content://media/internal/audio/media/27
This confirms the picker worked correctly.
Important Notes
No “Set Ringtone” Intent
Android does not provide an intent like:
android.intent.action.SET_RINGTONE
You must either:
-
Let the user pick only
-
Or apply the ringtone using:
WRITE_SETTINGSpermission- A Java-based extension (e.g. Taifun Settings)
Summary
Uses official Android intent
Works on modern Android versions
No special permissions needed
Fully compatible with App Inventor
Intent Action
android.intent.action.RINGTONE_PICKER
Returned Extra
android.intent.extra.ringtone.PICKED_URI