SLaks
2013-06-17 08:37
采纳率: 60.5%
浏览 6.4k

如何在 notification 上添加声音?

如何添加声音到一个notification中,这个notification是通过NotificationCompat.Builder创建的。我在res中创建了一个原始文件夹,然后添加了声音。那么现在如何把声音添加到notification中?
有关 Notification 代码:

 int NOTIFY_ID=100;
    Intent notificationIntent = new Intent(this, Notification.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
            .setContentIntent(pendingIntent)
            .setSmallIcon(R.drawable.notification)
            .setContentTitle("Warning")
            .setContentText("Help!")

    NotificationManager mgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mgr.notify(NOTIFY_ID, mBuilder.build());
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • 码密码密哄 2013-06-17 08:56
    最佳回答

    NotificationCompat.Builder mBuilder =
    new NotificationCompat.Builder(this);
    Notification notification = mBuilder.build();
    notification.sound = Uri.parse("your path");

    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题