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> | Parcelable.Creator that instantiates Notification objects | |
public int | The audio stream type to use when playing the sound. Should be one of the STREAM_ constants from AudioManager . | |
public RemoteViews | A large-format version of | |
public PendingIntent | The intent to execute when the expanded status entry is clicked. If this is an activity, it must include the | |
public RemoteViews | The view that will represent this notification in the expanded status bar. | |
public int | Specifies which values should be taken from the defaults. To set, OR the desired from | |
public PendingIntent | 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 | ||
public PendingIntent | An intent to launch instead of posting the notification to the status bar. | |
public int | The resource id of a drawable to use as the icon in the status bar. | |
public int | If the icon in the status bar is to have more than one level, you can set this. | |
public Bitmap | The bitmap that may escape the bounds of the panel and bar. | |
public int | The color of the led. | |
public int | The number of milliseconds for the LED to be off while it's flashing. | |
public int | The number of milliseconds for the LED to be on while it's flashing. | |
public int | The number of events that this notification represents. | |
public int | Relative priority for this notification. | |
public Uri | The sound to play. | |
public CharSequence | Text to scroll across the screen when this item is added to the status bar on large and smaller devices. | |
public RemoteViews | The view to show as the ticker in the status bar when the notification is posted. | |
public long[] | The pattern with which to vibrate. | |
public long | A timestamp related to this notification, in milliseconds since the epoch. |