最低SDK11,也就是3.0
private void testNotification() {
Intent intentMyLe = new Intent(this, MyLeFengActivity.class);
Intent intentSearch = new Intent(this, SearchActivity.class);
Intent intentCategory = new Intent(this, CategoryActivity.class);
Intent intentSale = new Intent(this, SaleActivity.class);
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(android.R.drawable.stat_notify_missed_call)
.setTicker("111")
.setWhen(System.currentTimeMillis() + 10000)
.setContentTitle("2222")
.setContentText("3333")
.setContentIntent(PendingIntent.getActivity(this, 0, <span style="font-family: Arial, Helvetica, sans-serif;">intentMyLe</span>, 0))
.setAutoCancel(true)
.setDeleteIntent(PendingIntent.getActivity(this, 0, intentSearch, 0));
builder.addAction(R.drawable.app, "haha", PendingIntent.getActivity(this, 0, intentCategory, 0));
builder.addAction(R.drawable.navigation_groupbuy_def, "团",
PendingIntent.getActivity(this, 0, intentSale, 0));
builder.addAction(R.drawable.navigation_luxuries_def, "钻",
PendingIntent.getActivity(this, 0, intentSale, 0));
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),
R.drawable.icon));
Notification notification = builder.getNotification();
mNotificationManager.notify(1, notification);
}