設置通知參數步驟:
?第一步:創(chuàng)建Builder對象(是notification的builder)并new出Notification.Builder(this),通過調用builder的方法來設置,setSmallIcon(R.drawable...),setTicker...;
?第二步(點擊后的響應):創(chuàng)建PendingIntent對象并賦值為PendingIntent.getActivity(context,requestCode,intent,flags):
? context:this;
? requestCode:請求碼,0;
? intent:創(chuàng)建Intent對象,在new中根據需求選擇構造的類.class;
? flags--0;
?第三步:創(chuàng)建Notification對象,并將builder.build()賦值//4.1即以上,要用builder.build()方法,以下要用builder.getNotification()方法;
?第四步:創(chuàng)建NotificationManager對象,因為是系統(tǒng)的常用服務,賦值為getSystemService(Context.NOTIFICATION_SERVICE),需強制轉化;調用成員函數notify(id,notification)來加載Notification,id是一個int值,表示notification的id,自行賦值即可;

well_liu
2014-10-10
3 回答
舉報
0/150
提交
取消
2016-01-18
總結的好!
2014-11-05
每次的總結都那么犀利
2014-11-04
設置通知參數步驟:
?第一步:創(chuàng)建Builder對象(是notification的builder)并new出Notification.Builder(this),通過調用builder的方法來設置,setSmallIcon(R.drawable...),setTicker...;
?第二步(點擊后的響應):創(chuàng)建PendingIntent對象并賦值為PendingIntent.getActivity(context,requestCode,intent,flags):
? context:this;
? requestCode:請求碼,0;
? intent:創(chuàng)建Intent對象,在new中根據需求選擇構造的類.class;
? flags--0;
?第三步:創(chuàng)建Notification對象,并將builder.build()賦值//4.1即以上,要用builder.build()方法,以下要用builder.getNotification()方法;
?第四步:創(chuàng)建NotificationManager對象,因為是系統(tǒng)的常用服務,賦值為getSystemService(Context.NOTIFICATION_SERVICE),需強制轉化;調用成員函數notify(id,notification)來加載Notification,id是一個int值,表示notification的id,自行賦值即可