当越来越铃声标题"小聚消息&QUOT ;,我得到11? [英] When getting ringtone title for "Hangout Message", I get 11?
问题描述
我试图得到一个警报,用户只需选择的名称。它的工作原理几乎我测试过的每一个报警。到目前为止,只有一个例外:视频群聊信息。我挑的报警与此:
I'm trying to get the name of an alarm that the user just selected. It works for ALMOST every alarm I've tested. So far there's only one exception: Hangout Message. I pick an alarm with this:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
if (alarm.getSound() != null) {
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, alarm.getSound());
} else {
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, alert);
}
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_ALARM);
startActivityForResult(intent, alarm.getID());
和我的 onActivityResponse
:
protected void onActivityResult(int id, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (id != -1) {
for (int i = 0; i < Alarms.size(); i++) {
Alarm alarm = Alarms.get(i);
if (alarm.getID() == id) {
alarm.setSound(ringtone);
alarm.UpdateView();
DB.SaveAlarm(alarm);
break;
}
}
}
}
}
我有一个pretty简单的方式来获得一个URI铃声名称:
I have a pretty simple way to get ringtone names from a URI:
Ringtone tone = RingtoneManager.getRingtone(this.Con, this.Sound);
AlarmSound.setText(tone.getTitle(this.Con).toUpperCase());
this.Con
是一个方面,一般是活动
,一个潜在的服务
。在报警
类是我自己的类。 this.Sound
是铃声的URI。对于所有其他的报警,这不是小聚的消息,这个伟大工程,并给我正确的铃声名称。视频群聊信息,我得到 11
并没有错误。 URI是内容://媒体/外部/音频/媒体/ 11
让我看到它得到 11
从,但我想那意思就是它的正式名称。我不想硬code为它的一个特例。
this.Con
is a context, generally an Activity
, potentially a Service
. The Alarm
class is my own class. this.Sound
is a URI for a ringtone. For every other alarm that's not Hangout Message, this works great and gives me the correct ringtone name. For Hangout Message, I get 11
and no errors. The URI is content://media/external/audio/media/11
so I see where it got 11
from, but I want to translate that to its proper name. I don't want to hard code a special case for it.
我怎样才能小聚的消息从这个URI?
How can I get Hangout Message from this URI?
我也想指出,在我的code,其中我设置了现有的URI,如果小聚消息是现有的声音,它会$ P $正确对选择它就像任何其他的铃声。铃声选择不正确地显示它的名称和应用程序不正确地播放声音在时机成熟时。
I do want to note that in my code where I set the Existing URI, if Hangout Message is the existing sound, it will pre-select it properly just like any other ringtone. The ringtone selector does show it's name properly and the app does play the sound correctly when the time comes.
编辑:我发现那里的股票的Android应用DeskClock中获取标题名称<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android-apps/4.4.2_r1/com/android/deskclock/AlarmClockFragment.java?av=f\"相对=nofollow>这里(行1356):
I've found where the stock Android DeskClock app gets the title name here (line 1356):
private String getRingToneTitle(Uri uri) {
// Try the cache first
String title = mRingtoneTitleCache.getString(uri.toString());
if (title == null) {
// This is slow because a media player is created during Ringtone object creation.
Ringtone ringTone = RingtoneManager.getRingtone(mContext, uri);
title = ringTone.getTitle(mContext);
if (title != null) {
mRingtoneTitleCache.putString(uri.toString(), title);
}
}
return title;
}
除了缓存,它没有做任何事情不同的比我。这使我相信,也许我在其他地方创造的问题,但我不知道还有什么可以影响到这一点。能生根或Xposed框架有这个特定的一个侧面影响?
Aside from the caching, it's not doing anything different than I am. This leads me to believe that maybe I'm creating the problem elsewhere but I have no clue what else could be impacting this. Could rooting or the Xposed framework have this specific a side affect?
推荐答案
如果我真的读过的日志,我可以在很久以前想通了这一点。
If I'd actually read the logs, I could have figured this out a long time ago.
由于它是由另一个应用程序提供的铃声,我需要一个新的许可来获得关于它的信息。我需要 READ_EXTERNAL_STORAGE
和添加后,它的工作完美。
Because it's a ringtone provided by another app, I need a new permission to get info about it. I needed READ_EXTERNAL_STORAGE
and after adding it, it worked perfectly.
这篇关于当越来越铃声标题&QUOT;小聚消息&QUOT ;,我得到11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!