Skip to content

Instantly share code, notes, and snippets.

@yyl
Created July 12, 2012 01:56
Show Gist options
  • Select an option

  • Save yyl/3095164 to your computer and use it in GitHub Desktop.

Select an option

Save yyl/3095164 to your computer and use it in GitHub Desktop.
Notification
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.local_service_started);
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, TrackingActivity.class), 0);
builder = new NotificationCompat.Builder(getBaseContext())
.setContentTitle("You are being tracked...")
.setContentText(text)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(contentIntent)
.setOngoing(true);
Notification notification = builder.getNotification();
// Send the notification.
mNM.notify(NOTIFICATION, notification);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment