振动和声音不会播放

时间:2011-06-08 14:16:48

标签: android

我有以下代码:

String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    CharSequence tickerText = "HI!";
    long when = System.currentTimeMillis();

    Notification notification = new Notification(R.drawable.droid,
            tickerText, when);

    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.flags |= Notification.DEFAULT_SOUND;
    notification.flags |= Notification.DEFAULT_LIGHTS;
    notification.flags |= Notification.DEFAULT_VIBRATE;

由于某种原因 - 除了自动取消之外,没有任何标志真正应用。

没有振动,没有声音,没有灯光。

这会导致什么? 我试过3.1&在2.2.1中

由于

1 个答案:

答案 0 :(得分:1)

尝试:

notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_VIBRATE;