新聞中心
NotificationSlot

創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),菏澤企業(yè)網(wǎng)站建設(shè),菏澤品牌網(wǎng)站建設(shè),網(wǎng)站定制,菏澤網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,菏澤網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
java.lang.Object
|---ohos.event.notification.NotificationSlot
public final class NotificationSlot
extends Object
implements Sequenceable定義了一個公共通知主題,它是一個包含通知音、振動、鎖屏顯示和級別的功能的集合。 您可以將這個類與一個應(yīng)用程序關(guān)聯(lián)起來,使應(yīng)用程序發(fā)布的所有通知都具有通知主題的特性。
一個應(yīng)用程序可以與一個或多個 NotificationSlot 實例相關(guān)聯(lián)。
Since:
1
嵌套類摘要
| 從接口 ohos.utils.Sequenceable 繼承的嵌套類/接口 |
|---|
| Sequenceable.ProducerT |
字段摘要
| 修飾符和類型 | 字段 | 描述 |
|---|---|---|
| static int | LEVEL_DEFAULT | 表示開啟通知功能,狀態(tài)欄顯示通知圖標(biāo),不帶橫幅,但有提示音。 |
| static int | LEVEL_HIGH | 表示開啟通知功能,狀態(tài)欄顯示通知圖標(biāo),帶有橫幅和提示音。 |
| static int | LEVEL_LOW | 表示通知功能開啟,狀態(tài)欄顯示通知圖標(biāo),無橫幅或提示音。 |
| static int | LEVEL_MIN | 表示開啟了通知功能,但狀態(tài)欄中不顯示通知圖標(biāo),沒有橫幅或提示音。 |
| static int | LEVEL_NONE | 表示通知功能已關(guān)閉。 |
| static int | LEVEL_UNDEFINED | 表示用戶未定義級別。 |
| static Sequenceable.ProducerNotificationSlot | PRODUCER | 從 Parcel 創(chuàng)建一個 NotificationSlot 實例。 |
構(gòu)造函數(shù)摘要
| 構(gòu)造函數(shù) | 描述 |
|---|---|
| NotificationSlot(String id, String name, int level) | 用于初始化 NotificationSlot 對象的 ID、名稱和級別的構(gòu)造函數(shù)。 |
方法總結(jié)
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| boolean | canEnableLight() | 獲取NotificationSlot對象中是否開啟通知燈,由setEnableLight(boolean)設(shè)置。 |
| boolean | canVibrate() | 獲取 NotificationSlot 對象的振動狀態(tài),由 setEnableVibration(boolean) 設(shè)置。 |
| void | enableBadge(boolean isShowBadge) | 設(shè)置收到通知后是否在主屏幕上顯示應(yīng)用程序圖標(biāo)標(biāo)記(應(yīng)用程序圖標(biāo)角落的數(shù)字或點)。 |
| void | enableBypassDnd(boolean bypassDnd) | 設(shè)置是否繞過系統(tǒng)中的請勿打擾 (DND) 模式。 |
| String | getDescription() | 獲取一個 NotificationSlot 對象的描述,由 setDescription(java.lang.String) 設(shè)置。 |
| String | getId() | 獲取 NotificationSlot 對象的 ID。 |
| int | getLedLightColor() | 獲取 NotificationSlot 對象中通知燈的顏色,由 setLedLightColor(int) 設(shè)置。 |
| int | getLevel() | 獲取 NotificationSlot 對象的級別,由 setLevel(int) 設(shè)置。 |
| int | getLockscreenVisibleness() | 獲取一個NotificationSlot對象在鎖屏上的通知顯示效果,由setLockscreenVisibleness(int)設(shè)置。 |
| String | getName() | 獲取 NotificationSlot 對象的名稱。 |
| String | getSlotGroup() | 獲取該NotificationSlot對象所屬的NotificationSlotGroup對象的ID,由setSlotGroup(java.lang.String)設(shè)置。 |
| Uri | getSound() | 獲取NotificationSlot對象的提示音,由setSound(ohos.utils.net.Uri)設(shè)置。 |
| long[] | getVibrationStyle() | 獲取此 NotificationSlot 中通知的振動樣式。 |
| boolean | isEnableBypassDnd() | 獲取 NotificationSlot 對象是否繞過免打擾模式,由 enableBypassDnd(boolean) 設(shè)置。 |
| boolean | isShowBadge() | 獲取 NotificationSlot 對象的應(yīng)用程序圖標(biāo)徽章狀態(tài),該狀態(tài)由 enableBadge(boolean) 設(shè)置。 |
| boolean | marshalling(Parcel out) | 將 NotificationSlot 對象編組到 Parcel 中。 |
| void | setDescription(String description) | 設(shè)置 NotificationSlot 對象的描述。 |
| void | setEnableLight(boolean isLightEnabled) | 指定在設(shè)備上收到通知時是否啟用通知燈,前提是此設(shè)備有通知燈。 |
| void | setEnableVibration(boolean vibration) | 設(shè)置是否在收到通知時啟用振動。 |
| void | setLedLightColor(int color) | 將通知燈的顏色設(shè)置為在設(shè)備上接收到通知時閃爍,前提是此設(shè)備具有通知燈并且使用值 true 調(diào)用 setEnableLight(boolean)。 |
| void | setLevel(int level) | 設(shè)置 NotificationSlot 對象的級別。 |
| void | setLockscreenVisibleness(int visibleness) | 設(shè)置是否以及如何在鎖定屏幕上顯示通知。 |
| void | setName(String name) | 設(shè)置 NotificationSlot 對象的名稱。 |
| void | setSlotGroup(String groupId) | 將 NotificationSlot 對象綁定到指定的 NotificationSlotGroup。 |
| void | setSound(Uri sound) | 為 NotificationSlot 對象設(shè)置提示音,在收到通知后播放。 |
| void | setVibrationStyle(long[] vibrationValues) | 設(shè)置此 NotificationSlot 中通知的振動樣式。 |
| String | toString() | 返回對象的字符串表示形式。 |
| boolean | unmarshalling(Parcel in) | 從 Parcel 中解組 NotificationSlot 對象。 |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 從接口 ohos.utils.Sequenceable 繼承的方法 |
|---|
| hasFileDescriptor |
字段詳細(xì)信息
LEVEL_DEFAULT
public static final int LEVEL_DEFAULT
表示開啟通知功能,狀態(tài)欄顯示通知圖標(biāo),不帶橫幅,但有提示音。
Since:
1
LEVEL_HIGH
public static final int LEVEL_HIGH
表示開啟通知功能,狀態(tài)欄顯示通知圖標(biāo),帶有橫幅和提示音。
Since:
1
LEVEL_LOW
public static final int LEVEL_LOW
表示通知功能開啟,狀態(tài)欄顯示通知圖標(biāo),無橫幅或提示音。
Since:
1
LEVEL_MIN
public static final int LEVEL_MIN
表示開啟了通知功能,但狀態(tài)欄中不顯示通知圖標(biāo),沒有橫幅或提示音。
Since:
1
LEVEL_NONE
public static final int LEVEL_NONE
表示通知功能已關(guān)閉。
Since:
1
LEVEL_UNDEFINED
public static final int LEVEL_UNDEFINED
表示用戶未定義級別。
這是一個保留的常量。 不要將其與任何通知相關(guān)聯(lián)。
Since:
3
PRODUCER
public static final Sequenceable.ProducerNotificationSlot PRODUCER
從 Parcel 創(chuàng)建一個 NotificationSlot 實例。
Since:
4
構(gòu)造函數(shù)詳細(xì)信息
NotificationSlot
public NotificationSlot(String id, String name, int level)
用于初始化 NotificationSlot 對象的 ID、名稱和級別的構(gòu)造函數(shù)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| id | 指定 NotificationSlot 對象的 ID。 ID 必須是唯一的,并且它的長度不能超過 1000 個字符(超出的部分會被自動截斷)。 |
| name | 指定 NotificationSlot 對象的名稱。 名稱必須對用戶可見,且長度不得超過 1000 個字符(超出部分會自動截斷)。 |
| level | 指定 NotificationSlot 對象的級別,決定通知的顯示效果。 該值可以是 LEVEL_NONE、LEVEL_MIN、LEVEL_LOW、LEVEL_DEFAULT 或 LEVEL_HIGH。 |
Since:
1
方法詳情
setLevel
public void setLevel(int level)
設(shè)置 NotificationSlot 對象的級別。
必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前設(shè)置 setLevel(int level)。 否則,設(shè)置將不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| level | 指定 NotificationSlot 對象的級別,決定通知的顯示效果。 該值可以是 LEVEL_NONE、LEVEL_MIN、LEVEL_LOW、LEVEL_DEFAULT 或 LEVEL_HIGH。 |
Since:
1
setName
public void setName(String name)
設(shè)置 NotificationSlot 對象的名稱。
無論是否通過 NotificationHelper#addNotificationSlot(NotificationSlot) 創(chuàng)建了 NotificationSlot 對象,setName(String) 的設(shè)置都有效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| name | 指定 NotificationSlot 對象的名稱。 名稱對用戶可見,長度不得超過 1000 個字符(超出部分自動截斷)。 |
Since:
1
setDescription
public void setDescription(String description)
設(shè)置 NotificationSlot 對象的描述。
無論是否通過 NotificationHelper#addNotificationSlot(NotificationSlot) 創(chuàng)建了 NotificationSlot 對象,setDescription(String) 的設(shè)置都有效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| description | 描述 NotificationSlot 對象。 描述對用戶可見,其長度不得超過 1000 個字符(超出部分將自動截斷)。 |
Since:
1
enableBadge
public void enableBadge(boolean isShowBadge)
設(shè)置收到通知后是否在主屏幕上顯示應(yīng)用程序圖標(biāo)標(biāo)記(應(yīng)用程序圖標(biāo)角落的數(shù)字或點)。
enableBadge(boolean) 必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前設(shè)置。 否則,設(shè)置將不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| isShowBadge | 指定是否顯示應(yīng)用程序圖標(biāo)標(biāo)志。 如果該值為 true,則啟用應(yīng)用程序圖標(biāo)徽章; 如果值為 false,則禁用應(yīng)用程序圖標(biāo)徽章。 |
Since:
1
enableBypassDnd
public void enableBypassDnd(boolean bypassDnd)
設(shè)置是否繞過系統(tǒng)中的請勿打擾 (DND) 模式。
enableBypassDnd(boolean)的設(shè)置只有在系統(tǒng)通知設(shè)置中為應(yīng)用程序開啟允許中斷功能時才會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| bypassDnd | 指定是否繞過應(yīng)用程序的 DND 模式。 如果該值為 true,則繞過免打擾模式; 如果該值為 false,則不繞過 DND 模式。 |
Since:
1
setEnableVibration
public void setEnableVibration(boolean vibration)
設(shè)置是否在收到通知時啟用振動。
必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前設(shè)置 setEnableVibration(boolean)。 否則,設(shè)置將不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| vibration | 指示是否在收到通知時啟用振動。 如果該值為true,則啟用振動; 如果值為 false,則禁用振動。 |
Since:
1
setLockscreenVisibleness
public void setLockscreenVisibleness(int visibleness)
設(shè)置是否以及如何在鎖定屏幕上顯示通知。
此方法指定在鎖定屏幕上顯示通知的不同效果,以保護(hù)用戶隱私。
該設(shè)置僅在系統(tǒng)通知設(shè)置中為應(yīng)用程序開啟鎖屏通知功能時生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| visibleness | 指定鎖屏上的通知顯示效果,可以設(shè)置為 NotificationRequest#VISIBLENESS_TYPE_PUBLIC、NotificationRequest#VISIBLENESS_TYPE_PRIVATE 或 NotificationRequest#VISIBLENESS_TYPE_SECRET。 |
Since:
1
setSound
public void setSound(Uri sound)
為 NotificationSlot 對象設(shè)置提示音,在收到通知后播放。
必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前設(shè)置 setSound(Uri)。 否則,設(shè)置將不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| sound | 指定提示音的路徑。 |
Since:
1
setEnableLight
public void setEnableLight(boolean isLightEnabled)
指定在設(shè)備上收到通知時是否啟用通知燈,前提是此設(shè)備有通知燈。
必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前設(shè)置 setEnableLight(boolean)。 否則,設(shè)置將不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| isLightEnabled | 指定是否啟用脈搏通知燈。 true 表示開啟通知燈,false 表示不開啟。 |
Since:
1
setLedLightColor
public void setLedLightColor(int color)
將通知燈的顏色設(shè)置為在設(shè)備上接收到通知時閃爍,前提是此設(shè)備具有通知燈并且使用值 true 調(diào)用 setEnableLight(boolean)。
必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前設(shè)置 setLedLightColor(int)。 否則,設(shè)置將不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| color | 指示通知燈的顏色。 |
Since:
1
setSlotGroup
public void setSlotGroup(String groupId)
將 NotificationSlot 對象綁定到指定的 NotificationSlotGroup。
必須在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 方法之前調(diào)用 setSlotGroup(String)。 否則,此方法不會生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| groupId | 表示要綁定的 NotificationSlotGroup 對象的 ID,必須是通過調(diào)用 NotificationHelper#addNotificationSlotGroup(NotificationSlotGroup) 創(chuàng)建的。 |
Since:
3
getId
public String getId()
獲取 NotificationSlot 對象的 ID。
返回:
返回 NotificationSlot 對象的 ID,由 NotificationSlot(java.lang.String,java.lang.String,int) 設(shè)置。
Since:
1
getName
public String getName()
獲取 NotificationSlot 對象的名稱。
返回:
返回由 setName(java.lang.String) 設(shè)置的 NotificationSlot 對象的名稱。
Since:
1
getDescription
public String getDescription()
獲取一個 NotificationSlot 對象的描述,由 setDescription(java.lang.String) 設(shè)置。
返回:
返回 NotificationSlot 對象的描述。
Since:
1
getLevel
public int getLevel()
獲取 NotificationSlot 對象的級別,由 setLevel(int) 設(shè)置。
返回:
返回 NotificationSlot 對象的級別。
Since:
1
isShowBadge
public boolean isShowBadge()
獲取 NotificationSlot 對象的應(yīng)用程序圖標(biāo)徽章狀態(tài),該狀態(tài)由 enableBadge(boolean) 設(shè)置。
返回:
如果啟用了應(yīng)用程序圖標(biāo)徽章,則返回 true; 否則返回 false。
Since:
1
isEnableBypassDnd
public boolean isEnableBypassDnd()
獲取 NotificationSlot 對象是否繞過免打擾模式,由 enableBypassDnd(boolean) 設(shè)置。
返回:
如果繞過 DND 模式,則返回 true; 否則返回 false。
Since:
1
canVibrate
public boolean canVibrate()
獲取 NotificationSlot 對象的振動狀態(tài),由 setEnableVibration(boolean) 設(shè)置。
返回:
如果啟用了振動,則返回 true; 否則返回 false。
Since:
1
getLockscreenVisibleness
public int getLockscreenVisibleness()
獲取一個NotificationSlot對象在鎖屏上的通知顯示效果,由setLockscreenVisibleness(int)設(shè)置。
返回:
返回 NotificationSlot 對象在鎖屏上的通知顯示效果。
Since:
1
getSound
public Uri getSound()
獲取NotificationSlot對象的提示音,由setSound(ohos.utils.net.Uri)設(shè)置。
返回:
返回 NotificationSlot 對象的提示音。
Since:
1
canEnableLight
public boolean canEnableLight()
獲取NotificationSlot對象中是否開啟通知燈,由setEnableLight(boolean)設(shè)置。
返回:
如果啟用通知燈,則返回 true; 否則返回 false。
Since:
1
getLedLightColor
public int getLedLightColor()
獲取 NotificationSlot 對象中通知燈的顏色,由 setLedLightColor(int) 設(shè)置。
返回:
返回通知燈的顏色。
Since:
1
getSlotGroup
public String getSlotGroup()
獲取該NotificationSlot對象所屬的NotificationSlotGroup對象的ID,由setSlotGroup(java.lang.String)設(shè)置。
返回:
返回此 NotificationSlot 對象所屬的 NotificationSlotGroup 的 ID。
Since:
3
setVibrationStyle
public void setVibrationStyle(long[] vibrationValues)
設(shè)置此 NotificationSlot 中通知的振動樣式。
如果將空數(shù)組或 null 傳遞給此方法,則系統(tǒng)將調(diào)用 setEnableVibration(boolean) 并將輸入?yún)?shù)設(shè)置為 false。 如果將有效值傳遞給此方法,則系統(tǒng)調(diào)用 setEnableVibration(boolean) 并將輸入?yún)?shù)設(shè)置為 true。 該方法僅在調(diào)用 NotificationHelper#addNotificationSlot(NotificationSlot) 之前生效。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| vibrationValues | 指示要設(shè)置的振動樣式。 |
Since:
4
getVibrationStyle
public long[] getVibrationStyle()
獲取此 NotificationSlot 中通知的振動樣式。
返回:
返回此 NotificationSlot 的振動樣式。
Since:
4
marshalling
public boolean marshalling(Parcel out)
將 NotificationSlot 對象編組到 Parcel 中。
進(jìn)程可以調(diào)用 unmarshalling(ohos.utils.Parcel) 方法從 Parcel 中解組 NotificationSlot 對象以實現(xiàn)進(jìn)程間通信 (IPC)。
指定者:
接口 Sequenceable 中的編組
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| out | 指示用于編組的 Parcel 對象。 |
返回:
如果編組成功,則返回 true; 否則返回 false。
Since:
1
unmarshalling
public boolean unmarshalling(Parcel in)
從 Parcel 中解組 NotificationSlot 對象。
指定者:
在接口 Sequenceable 中解組
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| in | 指示用于解組的 Parcel 對象。 |
返回:
如果解組成功,則返回 true; 否則返回 false。
Since:
1
toString
public String toString()
從類復(fù)制的描述:對象
返回對象的字符串表示形式。 通常,toString 方法返回一個“以文本方式表示”該對象的字符串。 結(jié)果應(yīng)該是一個簡潔但信息豐富的表示,易于人們閱讀。 建議所有子類重寫此方法。
Object 類的 toString 方法返回一個字符串,該字符串由對象作為其實例的類的名稱、at 符號字符“@”和對象哈希碼的無符號十六進(jìn)制表示形式組成。 換句話說,此方法返回一個等于以下值的字符串:
getClass().getName() + '@' + Integer.toHexString(hashCode()) 覆蓋:
類 Object 中的 toString
返回:
對象的字符串表示形式。
Since:
4
網(wǎng)頁名稱:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSNotificationSlot
URL地址:http://www.dlmjj.cn/article/djegdch.html


咨詢
建站咨詢
