Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasincs/101802 to your computer and use it in GitHub Desktop.
Save prasincs/101802 to your computer and use it in GitHub Desktop.
// Android notification that cancels automatically when user clicks
Notification notification = new Notification(R.drawable.icon, "Posit",
System.currentTimeMillis());
Intent intent = new Intent(MAIN_ACTIVITY,SyncService.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(MAIN_ACTIVITY, "Service started", "POSIT service started", pendingIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(R.string.addLabel, notification);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment