1. Get a reference to the NotificationManager:
2. Instantiate the Notification:
3. Define the Notification's expanded message and Intent:
4. Pass the Notification to the NotificationManager:
출처 : http://developer.android.com/guide/topics/ui/notifiers/notifications.html
String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
2. Instantiate the Notification:
int icon = R.drawable.notification_icon; CharSequence tickerText = "Hello"; long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
3. Define the Notification's expanded message and Intent:
Context context = getApplicationContext(); CharSequence contentTitle = "My notification"; CharSequence contentText = "Hello World!"; Intent notificationIntent = new Intent(this, MyClass.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
4. Pass the Notification to the NotificationManager:
private static final int HELLO_ID = 1;User 는 이제 Notification 을 통보 받는다.
mNotificationManager.notify(HELLO_ID, notification);
출처 : http://developer.android.com/guide/topics/ui/notifiers/notifications.html