2010-07-07 127 views
1
Notification notification = new Notification(icon, tickerText, when); 
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
notification.defaults |= Notification.DEFAULT_SOUND; 
notification.defaults |= Notification.DEFAULT_VIBRATE; 
notification.defaults |= Notification.DEFAULT_LIGHTS; 
notification.flags |= Notification.FLAG_AUTO_CANCEL; 

notification.flags |= Notification.FLAG_SHOW_LIGHTS; 
notification.ledARGB = 0xff00ff00; 
notification.ledOnMS = 300; 
notification.ledOffMS = 1000; 

Change in manifest : 
<uses-permission 
     android:name="android.permission.VIBRATE"></uses-permission> 

我已經加入上述代碼。它的運行沒有錯誤。但沒有看到效果。它運行在android 1.5上嗎?播放鈴聲和振動電話?

回答

1

您需要將此通知設置包裝到通知管理器調用中。

看到一些教程的notificationmanager

mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
mManager.notify(APP_ID, notification);