我想設置通知的振動和聲音。出於某種原因,它不是爲我工作:(以下是我想振動不能使用通知
NotificationManager notificationManager = getNotificationManager();
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
builder.setSound(alarmSound);
builder.setVibrate(new long[] { 1000, 1000, 1000 });
Notification notification = builder.setContentIntent(contentIntent)
.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true).setContentTitle(title).setPriority(Notification.PRIORITY_HIGH)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msgToDisply))
.setContentText(msgToDisply).build();
notificationManager.notify(NOTIFICATION, notification);
stopSelf();
而且
public NotificationManager getNotificationManager() {
return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
的代碼,我有權在我的清單
<uses-permission android:name="android.permission.VIBRATE" />
任何線索是什麼繼續?
但我使用NotificationCompat.Builder – Achayan
沒關係,你必須在我的代碼或@Panayiotis碼聲明震動功能!反正必須聲明! – BiggDawgg
爲什麼NotificationBuilder和Notification支持設置振動值? –