Code example for Notification.Builder

Methods: getNotification, setContentIntent, setLights, setSound, setVibrate

0
	private void broadcastNotification(Quake _quake) {
		// TODO Auto-generated method stub 
		Intent startActivityIntenet = new Intent(this, Earthquake.class);
		PendingIntent launchIntent = PendingIntent.getActivity(this, 0,
				startActivityIntenet, 0);
		earthquakeNotificationBuilder.setContentIntent(launchIntent)
				.setWhen(_quake.getDate().getTime())
				.setContentTitle("M: " + _quake.getMagnitude())
				.setContentText(_quake.getDetails());
 
		if (_quake.getMagnitude() > 6) {
			Uri ringURI = RingtoneManager
					.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 
			earthquakeNotificationBuilder.setSound(ringURI);
		} 
 
		double vibrateLength = 100 * Math.exp(0.53 * _quake.getMagnitude());
		long[] vibrate = new long[] { 100, 100, (long) vibrateLength };
		earthquakeNotificationBuilder.setVibrate(vibrate);
 
		int color;
		if (_quake.getMagnitude() < 5.4)
			color = Color.GREEN;
		else if (_quake.getMagnitude() < 6)
			color = Color.YELLOW;
		else 
			color = Color.RED;
 
		earthquakeNotificationBuilder.setLights(color, (int) vibrateLength,
				(int) vibrateLength);
 
		NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
		notificationManager.notify(NOTIFICATION_ID,
				earthquakeNotificationBuilder.getNotification());
 
	} 
 
	public static String TAG = "EARTHQUAKE_UPDATE_SERVICE";