开发者

Shared preferences - select ringtone basic implementation

I'm almost at a stage where my app is getting to a good state. So far for everything I have used just defaults but now I want the user to be able to select a ringtone to use for notifying them.

My code for defaults is:

        note.defaults |= Notification.DEFAULT_SOUND; 

Does anyone know where a good tutorial is, or have some code they could share for changing this to user selecta开发者_运维技巧ble ringtones? I've had a look at the documentation but found it a little confusing thus far. Any help is much appreciated as always.

Edit: I think the XML part of this looks ok, it's just the Java/Android side of it I'm having trouble with - thanks!


Basically, you add a RingtonePreference to your Preferences screen. This lets the user select a ringtone which will be saved to your SharedPreferences. In the part of your code where you say

note.defaults |= Notification.DEFAULT_SOUND;

instead do

note.sound = Uri.parse(context.getSharedPreferences("my_preferences_file_name", 0).getString("the_name_of_your_ringtone_preference", ""));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜