Android铃声偏好设置-获取数据
作者:互联网
我有一个铃声偏好.我如何获得选择?我有以下类型的代码:
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
标签:preference,ringtone,android 来源: https://codeday.me/bug/20191023/1914031.html