Android 铃声首选项 - 获取数据

标签 android ringtone preference

我有一个铃声偏好。我怎样才能得到选择?我有以下类型的代码:

if(preferences.getString("ringtonePref", "n/a") != ??)
            {
                Toast.makeText(TutorialPref.this,   "Chosen ringtone: silent", Toast.LENGTH_LONG).show();
            }
            else if(preferences.getString("ringtonePref", "n/a") != "DEFAULT_RINGTONE_URI" )
            {
                Toast.makeText(TutorialPref.this,   "Chosen ringtone: + default", Toast.LENGTH_LONG).show();
            }

最佳答案

这就是您将选择分配给通知实例的方式。

String strRingtonePreference = preferences.getString("ringtonePref", "DEFAULT_RINGTONE_URI");
notification.sound = Uri.parse(strRingtonePreference);

通知在哪里:

Notification notification = new Notification(icon, tickerText, time);

您可以在这里找到更多信息:http://developer.android.com/reference/android/app/Notification.html

关于Android 铃声首选项 - 获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4761467/

相关文章:

android - 我如何以编程方式获取android中的默认铃声列表?

android - 在 Resume 的 PreferenceActivity 中重新加载首选项

Android 自定义首选项更改覆盖

android - .iml 文件在删除后重新生成

android - listView android 在一个列表中可点击,在其他列表中不可点击

java - 将 InputStream 转换为 BufferedReader

android - 从内容中获取资源id ://settings/system/ringtone?

android - 如何无限循环在Android中播放铃声?

ios - 如何让用户选择在 iOS 应用程序中使用的货币?

android - 如何使用 android.hardware.camera.external 在 android 中打开 USB 摄像头