極光自定義訊息

2021-07-31 04:21:54 字數 4512 閱讀 5685

先自定義receiver?

1

2

3

4

5

6

7

8

9

? 1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

privatestaticfinalstring tag ="myreceiver";

@override

publicvoidonreceive(context context, intent intent)elseif(jpushinte***ce.action_message_received.equals(intent

.getaction()))elseif(jpushinte***ce.action_notification_received.equals(intent

.getaction()))elseif(jpushinte***ce.action_notification_opened.equals(intent

.getaction()))

}

在receivingnotification()中自定義notification通知欄?

還有一種自定義通知欄,帶有下拉效果。是官網介紹的。

布局檔案customer_notitfication_layout.xml?

1

2

3

4

5

6

7

8

9

10

">

初始化通知效果?

1

2

3

4

5

6

7

8

9

custompushnotificationbuilder builder =newcustompushnotificationbuilder(

mainactivity.this, r.layout.customer_notitfication_layout,

r.id.icon, r.id.title, r.id.text);

// 指定定製的 notification layout

builder.statusbardrawable = r.drawable.notification_icon;

// 指定最頂層狀態列小圖示

builder2.layouticondrawable = r.drawable.notification_icon;

// 指定下拉狀態列時顯示的通知圖示

jpushinte***ce.setpushnotificationbuilder(1, builder1);

這裡面有乙個方法builder.statusbardrawable,這個設定的是乙個狀態列圖示,不是下拉介面裡那個。當來通知時,手機頂部會滾動提示一下來訊息了。這裡設定的圖示就是剛來通知在頂部提示的,而不是上圖里紅框裡那個。

這種帶下來效果

還有一種簡版的,也是官網demo,mark一下。設定成預設,傳送通知?

1

2

3

4

5

6

7

8

basicpushnotificationbuilder builder2 =newbasicpushnotificationbuilder(

mainactivity.this);

builder2.statusbardrawable = r.drawable.logo;

builder2.notificationflags = notification.flag_auto_cancel;// 設定為自動消失

builder2.notificationdefaults = notification.default_sound

| notification.default_vibrate | notification.default_lights;// 設定為鈴聲與震動都要

jpushinte***ce.setdefaultpushnotificationbuilder(builder2);

jpushinte***ce.setpushnotificationbuilder(2, builder2);

setpushnotificationbuilder(2, builder2);設定builder2的樣式編號為2,傳送時指定編號傳送。

自定義訊息

自定義訊息的響應和資源訊息的響應有很多類似之處 資源訊息的響應是以資源的id號作為標識的 自定義的訊息要自己宣告訊息id。一 定義 第一步要宣告訊息 definewm mymsgwm user 200 第二步要在類宣告中宣告訊息對映 declare message map 第三步要在類宣告中定義訊息...

VC自定義訊息

示例 主對話方塊a edit控制項 副對話方塊b edit控制項 將b中edit內容在其銷毀後,顯示在a中edit中 1 自定義訊息 define wm mymsg wm user 100 2 b cpp afxgetmainwnd sendmessage wm mymsg,wparam 0,lpa...

MFC自定義訊息

訊息機制是windows的典型執行機制,在mfc中有很多的訊息如wm btn 等。但是在有些情況下我們需要自定義一些訊息去做一些我們需要的功能,mfc的嚮導不能幫助我們做到這一點,我們可以通過新增相應的 去完成這個功能。新增自定義訊息操作如下 1.建立mfc工程,如基於對話方塊的應用程式,test。...