android Notification 的使用

http://www.cnblogs.com/newcj/archive/2011/03/14/1983782.html

Android 状态栏通知Notification用法

http://www.pocketdigi.com/20100905/89.html

android清除通知栏消息

http://www.2cto.com/kf/201201/116590.html

public class SmsNotification {
public static void showSmsNotification(Context context) {
List<TxrjMessage> list = SmsDataManager.getUnreadMessages(context);
if(list.size()>0){
notify(context, list.get(0));
}
}
public static void notify(Context context, TxrjMessage msg) {
NotificationManager notifiMgr = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
/*Notification notifi = new Notification(R.drawable.sms_icon,
"短信", System.currentTimeMillis()); */
Notification notifi = new Notification();
notifi.icon = R.drawable.sms_icon;
notifi.tickerText = msg.getBody();
notifi.when = System.currentTimeMillis();
notifi.number = 1;
/*notifi.flags = Notification.FLAG_ONGOING_EVENT
| Notification.FLAG_NO_CLEAR | Notification.FLAG_SHOW_LIGHTS;*/
notifi.defaults = Notification.DEFAULT_ALL;
Intent itNotifi = new Intent(context, MessageListActivity.class);
String displayName = TextUtils.isEmpty(msg.getName()) ? msg.getNumber() : msg.getName();
itNotifi.putExtra(TxrjConstant.EXTRA_THREAD_DISPLAY_NAME, displayName);
itNotifi.putExtra(TxrjConstant.EXTRA_THREAD_NUMBER, msg.getNumber());
PendingIntent pendIt = PendingIntent.getActivity(context,
TxrjConstant.REQUEST_READ_NOTIFICATION, itNotifi, 0);
Log.i("txrjsms", "name:"+msg.getName()+", number:"+msg.getNumber());
notifi.setLatestEventInfo(context, displayName, msg.getBody(), pendIt);
notifiMgr.notify(0, notifi);
}
}

Field-Type

Field-Name

Description

public static final Creator<Notification>

CREATOR

Parcelable.Creator that instantiates Notification objects

public int

audioStreamType

The audio stream type to use when playing the sound. Should be one of the STREAM_ constants from AudioManager.

public RemoteViews

bigContentView

A large-format version of contentView, giving the Notification an opportunity to show more detail. The system UI may choose to show this instead of the normal content view at its discretion.

public PendingIntent

contentIntent

The intent to execute when the expanded status entry is clicked. If this is an activity, it must include theFLAG_ACTIVITY_NEW_TASK flag, which requires that you take care of task management as described in the Tasks and Back Stackdocument. In particular, make sure to read the notification section Handling Notifications for the correct ways to launch an application from a notification.

public RemoteViews

contentView

The view that will represent this notification in the expanded status bar.

public int

defaults

Specifies which values should be taken from the defaults. To set, OR the desired from DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS. For all default values, use DEFAULT_ALL.

public PendingIntent

deleteIntent

The intent to execute when the notification is explicitly dismissed by the user, either with the "Clear All" button or by swiping it away individually. This probably shouldn't be launching an activity since several of those will be sent at the same time.

public int

flags

public PendingIntent

fullScreenIntent

An intent to launch instead of posting the notification to the status bar.

public int

icon

The resource id of a drawable to use as the icon in the status bar.

public int

iconLevel

If the icon in the status bar is to have more than one level, you can set this.

public Bitmap

largeIcon

The bitmap that may escape the bounds of the panel and bar.

public int

ledARGB

The color of the led.

public int

ledOffMS

The number of milliseconds for the LED to be off while it's flashing.

public int

ledOnMS

The number of milliseconds for the LED to be on while it's flashing.

public int

number

The number of events that this notification represents.

public int

priority

Relative priority for this notification.

public Uri

sound

The sound to play.

public CharSequence

tickerText

Text to scroll across the screen when this item is added to the status bar on large and smaller devices.

public RemoteViews

tickerView

The view to show as the ticker in the status bar when the notification is posted.

public long[]

vibrate

The pattern with which to vibrate.

public long

when

A timestamp related to this notification, in milliseconds since the epoch.

更多相关文章

  1. android消息机制
  2. android的消息处理机制(图+源码分析)——Looper,Handler,Message
  3. android消息处理机制学习(一)-Handler,Message,MessageQueue,Loope
  4. Android Handler机制8之消息的取出与消息的其他操作
  5. Android 状态栏通知Notification(转载)
  6. Android安全加密:消息摘要Message Digest
  7. android消息机制原理详解
  8. Android消息循环实现原理分析

随机推荐

  1. Android中NDK的so文件产生和使用
  2. OpenJDK 1.8的安装,build Android N
  3. android 多线程断点下载,listview 模式 开
  4. 在android studio中配置ndk开发环境
  5. android 屏蔽home键
  6. android 金额输入限制,EditText保留两位小
  7. Android onActivityResult传值
  8. Jenkins android集成遇到的问题
  9. 我的Android进阶之旅------>android Matr
  10. Android学习笔记之ProgressDialog