Skip to content

Instantly share code, notes, and snippets.

@Red-Folder
Created September 24, 2012 20:30
Show Gist options
  • Save Red-Folder/3778177 to your computer and use it in GitHub Desktop.
Save Red-Folder/3778177 to your computer and use it in GitHub Desktop.
Phonegap Service Tutorial - Part 3 - TwitterService.java - showNotification
public void showNotification( String contentTitle, String contentText ) {
int icon = R.drawable.ic_stat_notification;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, contentTitle, when);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(this, TwitterExampleActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
NotificationManager nm = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1, notification);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment