1

私は次のようなアラーム音で通知を実装しました:

    PendingIntent pi = PendingIntent.getActivity(context, id, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    Notification note = new Notification(R.drawable.icon, "Alarm", System.currentTimeMillis());
    note.setLatestEventInfo(context, "Alarm", title + " (alarm)", pi);
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    if(alarmSound == null){
        alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        if(alarmSound == null){
            alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        }
    }
    note.sound = alarmSound;
    note.defaults |= Notification.DEFAULT_VIBRATE;
    note.flags |= Notification.FLAG_AUTO_CANCEL;
    manager.notify(id, note);

アラームの音は鳴りますが、私が直面している問題は、通知バーを下にドラッグするまで、アラームが鳴り続けることです。これが再生されている間、現在再生中のアラームに関する情報を含むダイアログ(ポップアップ)としてアクティビティを表示しています。ダイアログ(ポップアップアクティビティ)にあるボタンでこのアラーム音をキャンセルできるようにしたい。

どうすればこれを達成できますか?ありがとう。

4

1 に答える 1

1

ダイアログボタンでサウンドをキャンセルするにmanager.cancel(id)は、IDをクリックします。IDは、通知を作成したときに設定したIDです。manager.notify(id,note)

于 2012-05-16T14:50:44.407 に答える