对于我正在开发的应用程序,我想向用户发送一个非常需要注意的通知。为此,我有以下代码:
public void showNotification() {
// Show a notification in the notification bar
Notification notification = new Notification(R.drawable.ic_launcher, "Notification", System.currentTimeMillis());
notification.flags = Notification.PRIORITY_MAX | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.FLAG_INSISTENT | Notification.DEFAULT_LIGHTS;
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this, "Title", "Text", contentIntent);
mNotificationManager.notify(R.string.app_name, notification);
}
在清单中:
<uses-permission android:name="android.permission.VIBRATE"/>
但是,这不会振动或显示灯光。有谁知道为什么这不起作用?