【问题标题】:Sound problem in Notification in Emulator模拟器通知中的声音问题
【发布时间】:2011-07-29 07:00:04
【问题描述】:

我想在模拟器中播放通知声音,但它不起作用; 我愿意:

notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
Uri u = Uri.parse("android.resources://my.package.name/" + R.raw.customsound);
notification.sound = u;

customsound 与 mediaplayer 一起播放得很好,但在通知中它除了跟随 LogCat 之外什么都没有:

07-29 12:44:36.326: INFO/StagefrightPlayer(34): setDataSource('/system/media/audio/ui/Effect_Tick.ogg') 07-29 12:44:36.396: WARN/AudioService(61): MediaPlayer IOException: java.io.IOException: Prepare failed.: status=0x1 07-29 12:44:36.396: DEBUG/MediaPlayer(61): 无法在客户端打开文件,正在尝试服务器端 07-29 12:44:36.446: WARN/NotificationService(61): java.io.IOException: Prepare failed.: status=0x1 07-29 12:44:36.446: WARN/NotificationService(61): 在 com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:90) 07-29 12:03:34.712: WARN/AudioService(61): MediaPlayer IOException: java.io.IOException: Prepare failed.: status=0x1

【问题讨论】:

    标签: android audio notifications


    【解决方案1】:

    试试这个代码

    notification.sound =Uri.parse("android.resource://" + getPackageName() + "Name OF audio store in raw folder");
    

    【讨论】:

    • 感谢您的回答,但我已经尝试过这种方式,似乎没有任何效果,LogCat 中再次出现相同的异常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多