Created
September 16, 2010 20:29
-
-
Save fornwall/583106 to your computer and use it in GitHub Desktop.
Snippets about android notifications
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
int icon = R.drawable.notification_icon; | |
CharSequence tickerText = "Hello"; | |
long when = System.currentTimeMillis(); | |
Notification notification = new Notification(icon, tickerText, when); | |
CharSequence contentTitle = "My notification"; | |
CharSequence contentText = "Hello World!"; | |
Intent notificationIntent = new Intent(this, MyActivity.class); | |
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); | |
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); |
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
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
manager.notify(NOTIFICATION_ID, notification); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment