Skip to content

Instantly share code, notes, and snippets.

@fornwall
Created September 16, 2010 20:29
Show Gist options
  • Select an option

  • Save fornwall/583106 to your computer and use it in GitHub Desktop.

Select an option

Save fornwall/583106 to your computer and use it in GitHub Desktop.

Revisions

  1. fornwall revised this gist Sep 16, 2010. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions CreatingANotification.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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);
  2. fornwall revised this gist Sep 16, 2010. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion GettingANotificationManager.java
    Original file line number Diff line number Diff line change
    @@ -1 +1,2 @@
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE;);
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(NOTIFICATION_ID, notification);
  3. fornwall renamed this gist Sep 16, 2010. 1 changed file with 0 additions and 0 deletions.
  4. fornwall renamed this gist Sep 16, 2010. 1 changed file with 0 additions and 0 deletions.
  5. fornwall created this gist Sep 16, 2010.
    1 change: 1 addition & 0 deletions android-notifications
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE;);