RingtonePreference で RingtoneManager を使用しています。デフォルトの着信音を使用するときは問題ありませんが、構成済みの着信音を使用すると数分間再生されます...曲の長さが数分なのか、ループ再生されるのかわかりません...
ここに私のコード:
private static void playNotificationSound(Context context) {
RingtoneManager rm = new RingtoneManager(context);
String ringtone = MySharedPreferences.ringtone(context);
Uri uri = null;
if(ringtone == null)
uri = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
else
uri = Uri.parse(ringtone);
if (uri != null) {
Ringtone rt = RingtoneManager.getRingtone(context, uri);
if (rt != null) {
rt.setStreamType(AudioManager.STREAM_NOTIFICATION);
rt.play();
}
}
}
通知付きの曲を再生するために使用していますが、電話で5分間再生したくありません...