2013-03-20 59 views
0

嗨,夥伴我試圖開發一個應用程序,需要在特定時間向用戶發送通知。在互聯網上,我發現這個代碼,但日食說,它已被棄用。 你知道哪個是用我的API來完成它的正確方法嗎? (16)已棄用Android狀態欄代碼

NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 

int icon = R.drawable.worldmap2; 
CharSequence tickerText = "Hello"; 
long when = System.currentTimeMillis(); 
Notification notification = new Notification(icon, tickerText,when); 
Context context = getApplicationContext(); 
CharSequence contentTitle = "My notification"; 
CharSequence contentText = "Hello World!"; 
final Intent intent1 = new Intent(context, HttpExampleLimits.class); 
PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent1, 0); 
notification.setLatestEventInfo(context, contentTitle,contentText, pIntent); 


nm.notify(1, notification); 

非常感謝!

回答