Created
September 24, 2012 20:30
-
-
Save Red-Folder/3778177 to your computer and use it in GitHub Desktop.
Phonegap Service Tutorial - Part 3 - TwitterService.java - showNotification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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