- Get a reference to the NotificationManager:
    
String ns = Context.NOTIFICATION_SERVICE; 
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); 
     
    - Instantiate the Notification:
    
int icon = R.drawable.notification_icon; 
    CharSequence tickerText = "Hello"; 
    long when = System.currentTimeMillis(); 
     
    Notification notification = new Notification(icon, tickerText, when); 
     
    - 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); 
     
    - Pass the Notification to the NotificationManager:
    
private static final int HELLO_ID = 1; 
     
    mNotificationManager.notify(HELLO_ID, notification); 
    That's it. Your user has now been notified. 
     
 
		 
		
	 
	  
	 
	
				
			  | 
		 
		 
	 | 
	
		
		
			
			
			
			
				
	 |  | 日 | 一 | 二 | 三 | 四 | 五 | 六 | 
|---|
 | 31 | 1 | 2 | 3 | 4 | 5 | 6 |  | 7 | 8 | 9 | 10 | 11 | 12 | 13 |  | 14 | 15 | 16 | 17 | 18 | 19 | 20 |  | 21 | 22 | 23 | 24 | 25 | 26 | 27 |  | 28 | 29 | 30 | 1 | 2 | 3 | 4 |  | 5 | 6 | 7 | 8 | 9 | 10 | 11 |  
  | 
			 
			 
				
			
常用链接
留言簿
		随笔档案
		
				
			
	
		文章档案
		
				
			
	
		相册
		
				
			
	
搜索
最新评论
	 
阅读排行榜
评论排行榜
			
			 
			
			 | 
		 
		 
	 |