【问题标题】:Android: stop sound notificationAndroid:停止声音通知
【发布时间】:2012-06-08 15:29:59
【问题描述】:

我使用 NotificationManager 播放声音。但是当我按任意键时,我不知道如何停止它。例如,后退按钮。太感谢了~~~^^

NotificationManager manager 
    = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

Notification notification = new Notification(); 
notification.sound=Uri.parse("android.resource://" 
    + getPackageName() + "/" +R.raw.fin); 

manager.notify(1, notification);

【问题讨论】:

    标签: android android-notifications notificationmanager


    【解决方案1】:

    我相信 NotificationManager 使用 MediaPlayer 来播放声音。 默认情况下,这会播放您的整个声音。 所以你需要打电话给 mediaplayer.stop。 您是否尝试过取消通知? notification Cancel

    【讨论】:

    • 嗯...是的,我只是想停止它...或退出此通知。无论如何,谢谢你的回复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多