我正在製作一個程序,我希望應用程序發出通知。當通知消失時,只顯示股票代碼文本。沒有聲音或振動或光線伴隨着它。通知沒有發出聲音或振動?
這裏是我的代碼示例:
int icon = R.drawable.icon;
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Countdown Complete!";
Intent intent = new Intent();
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
Notification notification = new Notification(icon, myCountDown.getName() + " is completed!", System.currentTimeMillis());
long[] vibrate = {0,100,200,300};
notification.vibrate = vibrate;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.setLatestEventInfo(context, contentTitle, contentText, pendingIntent);
notificationManager.notify(myCountDown.getId(), notification);
是的聲音是開着的,當通知消失時,我選擇了一個聲音。我會嘗試代碼,看看是否有用。 – Tj5 2012-01-19 17:56:56
我試過這個,並意識到這是我至少爲振動做什麼,我的代碼應該通知通知管理器使用燈光和聲音的默認值...所以它仍然不起作用 – Tj5 2012-01-24 21:39:56