Send Notification : Notification « Core Class « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » Core Class » Notification 
Send Notification
  

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

 class Helper {
    public static void sendNotification(Context context, int notificationId,
            String title, String content) {
        // Show a notification.
        final NotificationManager nMgr = (NotificationManagercontext.getSystemService(
                context.NOTIFICATION_SERVICE);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0new Intent()0);
        Notification notif = new Notification(R.drawable.icon, title, 
                System.currentTimeMillis());
        notif.setLatestEventInfo(context, title, (content == null"" : content, contentIntent);
        nMgr.notify(notificationId, notif);
    }
}

   
    
  
Related examples in the same category
1.Notification event
2.How to use Notification
3.Look up the notification manager service
4.Cancel the notification that we started
5.Using NotificationManager
6.Demonstrates adding notifications to the status bar
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.