我正在制作一个程序,我希望应用程序发出通知。当通知消失时,只显示股票代码文本。没有声音或振动或光线伴随着它。通知没有发出声音或振动?
这里是我的代码示例:
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