Android 自定义Notificiation sound 步骤

  • 在res新建raw目录,将音频文件拷贝到该目录下.
    eg: 文件名为sound.wav
  • 获取Uri

    1
    2
    3
    4
    String filePath = "android.resource://"+ getPackageName() + "/raw/sound"
    Uri sound = Uri.parse(respath);
    notificiation.setSound(sound)

注意 : filePath的文件名称不带后缀(亲测)

<<<<<<< HEAD:2015/12/22/Android中自定义通知声音/index.html