노무현 대통령 배너

Double-J's World

blog logo image

Double-J's World » Search » Results » Articles

status bar와 관련된 글 1개

  1. 2009.11.05 To create a status bar notification / Double-J

Double-J's World » Programming/Android

To create a status bar notification

Double-J | 2009. 11. 5. 11:02

1. Get a reference to the NotificationManager:
1String ns = Context.NOTIFICATION_SERVICE;
2NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);


2. Instantiate the Notification:
1int icon = R.drawable.notification_icon;
2CharSequence tickerText = "Hello";
3long when = System.currentTimeMillis();
4 
5 
6Notification notification = new Notification(icon, tickerText, when);


3. Define the Notification's expanded message and Intent:
1Context context = getApplicationContext();
2CharSequence contentTitle = "My notification";
3CharSequence contentText = "Hello World!";
4Intent notificationIntent = new Intent(this, MyClass.class);
5PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
6 
7notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);


4. Pass the Notification to the NotificationManager:
1private static final int HELLO_ID = 1;
2 
3 
4mNotificationManager.notify(HELLO_ID, notification);
User 는 이제 Notification 을 통보 받는다.

출처 : http://developer.android.com/guide/topics/ui/notifiers/notifications.html


(go to top)