Published in


Notification Channel 自訂音效

自從由 Android 8 開始,如果要顯示 notification 的話就一定要指定一個 notification channel ,否則系統不會顯示。Notification channel 的目的是讓用戶能自行調節 app 的各式 notification 的提示方法,例如有沒有音效、會不會彈出 heads-up notification 之類。如果 app 想自訂 notification 的聲音亦都要經 notification channel 設定(但用戶可以之後自行變更 notification channel 的音效)

但是要留意,設定自訂音效時那個 Uri 要用檔案名稱來設定,不要用 resource ID。以下是錯誤例子:

val uri = Uri.Builder()




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eric Li

Eric Li

Hongkonger + Android developer

More from Medium

Kotlin Program Execution Flow

Koin with Navigation component

Foldable Devices Android An Initiative

Dagger 2’s naming convention is suboptimal, let’s fix it