私は非常に時間に敏感な情報をユーザーに通知するアプリを書いています。多くのユーザーは、短い通知音ではなく、電話の着信音を使用したいと考えています。PreferenceScreen で設定してこの機能を有効にしましandroid:ringtoneType="all"
たが、電話の着信音を選択すると、ユーザーが通知バーに触れるまで永遠に再生し続けることを除いて、うまく機能します...どうすれば 30 秒ほど後にオフにできますか? 、通知をキャンセルせずに?
C2DM受信機で使用しているコードは次のとおりです。
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification(....)
....
String ringtone = PreferenceManager.getDefaultSharedPreferences(context).getString("ringtone", "");
notif.sound = Uri.parse(ringtone);
notif.audioStreamType = AudioManager.STREAM_NOTIFICATION;
nm.notify(1, notif);