Notification

左边的大图为 largeIcon

右边的Android小机器人为smallIcon


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.setContentText("ContentText");
		builder.setContentTitle("ContentTitle");
		
		builder.setSmallIcon(R.drawable.ic_launcher);
		builder.setLargeIcon(BitmapFactory.decodeStream(getAssets().open("a.png")));
		builder.setTicker("Ticker");
		
		Notification notification = builder.build();
		
		NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
		manager.notify(1, notification);
		
	}


你可能感兴趣的:(notification)