The easiest way I know how to do this involves extending
PreferenceActivity to load preferences from a xml file by calling
addPreferencesFromResource(R.xml.preferences);
The preferences.xml entry should be something like:
<RingtonePreference
android:key="ringtone"
android:title="@string/YOUR_TITLE"
android:summary="@string/YOUR_SUMMARY"
android:ringtoneType="all"
android:showDefault="true"
android:showSilent="true"
/>
Then in your activity, to access the data:
Uri uri = String.valueOf
(android.provider.Settings.System.DEFAULT_NOTIFICATION_URI);
String ringTone = app_preferences.getString("ringtone", uri);
I'm not sure how to do this outside of extending PreferenceActivity
with xml - RingtonePreference.
This is based on information from "The Busy Coder's Guide to Android
Development". Check out the source: http://commonsware.com/Android/
(under 'Facts and Resources') and navigate to 'Prefs' folder.
Can also be seen here: http://androidguys.com/?p=1891
Hope this helps,
Paul Burke
[email protected]
pub:"iPaul Pro"
On Jul 2, 11:29 am, John Reese <[email protected]> wrote:
> Hi all,
>
> I apologize if this has been covered somewhere already, but after
> looking through all the SDK documentation, searching google (and the
> Android groups), and fruitless requests on #android, I'm stuck asking
> for help on this list.
>
> In my application, I'm sending notifications to the user, and I would
> like to allow the user to select, from a settings screen/activity, the
> ringtone used for the notification. I know that the RingtoneManager
> object can return a Cursor via getCursor(), but I can't seem to figure
> out the appropriate method of sticking that data into the Spinner.
> I've tried using a SimpleCursorAdapter as best as I could figure out
> with the help of Spinner-related information online, but it seems that
> any efforts always result in my app crashing/force-closing whenever I
> try to load the settings activity.
>
> Can anyone point me to any tutorial, app code, or SDK documentation
> that might help cover this specific usage? I've seen plenty of apps
> on the market use something exactly like what I want (Locale, K-9,
> etc), but none of those apps seem to be open source, so I can't look
> at them.
>
> Any help would be greatly appreciated. Cheers
>
> --
> John Reese
> LeetCode.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---