左边的大图为 largeIcon
右边的Android小机器人为smallIcon
若不设置largeIcon,则为以下样式
setTicket:设置Notification出来时在状态栏显示的信息
另外,setContentInfo("ContentInfo")和setNumber(4);其显示位置一致
public void notify(View view) throws Exception
{
//Notification add Light/Sound/Vibrate
int defaultType = 0;
defaultType |= Notification.DEFAULT_LIGHTS;
defaultType |= Notification.DEFAULT_SOUND;
defaultType |= Notification.DEFAULT_VIBRATE;
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setDefaults(defaultType);
// builder.setContentInfo("ContentInfo");
builder.setNumber(4);
builder.setContentText("ContentText");
builder.setContentTitle("ContentTitle");
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setLargeIcon(BitmapFactory.decodeStream(getAssets().open("a.png")));
builder.setTicker("Ticker");
builder.addAction(android.R.drawable.ic_delete, "Delete1", null);
builder.addAction(android.R.drawable.ic_delete, "Delete2", null);
builder.setStyle(new NotificationCompat.BigTextStyle()
.setBigContentTitle("BigTextTitle")
.setSummaryText("SummaryText")
.bigText("BigTextBigText"));
Notification notification = builder.build();
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, notification);
}