0
對於我正在開發的應用程序,我想向用戶發送非常注意要求的通知。要做到這一點,我有以下代碼:通知不振動或顯示燈光
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"/>
然而,這不振動或顯示燈。有人知道爲什麼這不起作用嗎?