Как отключить вибрацию при появлении уведомления?
Я использовал startForground(int, int);
в PlayerService
классе.
- Я обновляю свое уведомление о состоянии воспроизведения и паузы, пока уведомлениеОбновления сообщают, что он начинает вибрировать, и я хочу отключить его навсегда.
Какие-либо решения?
ПРИМЕЧАНИЕ. Я пробовал много способов, но он снова начинает вибрировать.
builder.setDefault(Notification.DEFAULT_ALL);
builder.setVibrate(new long[]{0L})
uilder.setVibrate(new long[]{01, 01})
NotificationManager notificationManager;
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel;
builder = new NotificationCompat.Builder(this);
String title = playlist().get(play_song_id).get(1);
String content = getSongArtists();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
channel = new NotificationChannel("lawanmusic", "lawanmusic", NotificationManager.IMPORTANCE_HIGH);
channel.setLightColor(getColor(R.color.colorAccent));
channel.enableVibration(false);
channel.setVibrationPattern(new long[]{ 01, 01 });
channel.enableVibration(false);
channel.setImportance(NotificationManager.IMPORTANCE_DEFAULT);
builder.setChannelId(channel.getId());
notificationManager.createNotificationChannel(channel);
}
builder.setDefaults(Notification.DEFAULT_ALL | -Notification.DEFAULT_VIBRATE).setVibrate(new long[]{ 0L });
builder.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle().setShowActionsInCompactView(0,1,2).setCancelButtonIntent(null).setMediaSession(new MediaSessionCompat(this, "media").getSessionToken()).setShowActionsInCompactView());
builder.setContentTitle(title);
builder.setContentText(content);
@DrawableRes int icon = R.drawable.play_icon_notification;
builder.setSmallIcon(icon);
builder.setLargeIcon(getSongCover());
PendingIntent pendingIntent = PendingIntent.getActivity(this, Constants.NOTIFICATION_ID, new Intent(this, ActivityMain.class).putExtra("player", true), PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
final PendingIntent prev = PendingIntent.getBroadcast(this, Constants.NOTIFICATION_ID, new Intent(this, PlayerReceiver.class).setAction(PREV_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.notification_prev, "Prev", prev);
final PendingIntent pause = PendingIntent.getBroadcast(this, Constants.NOTIFICATION_ID, new Intent(this, PlayerReceiver.class).setAction(PAUSE_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.notification_pause, "Pause", pause);
final PendingIntent next = PendingIntent.getBroadcast(this, Constants.NOTIFICATION_ID, new Intent(this, PlayerReceiver.class).setAction(NEXT_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.notification_next, "Next", next);
final PendingIntent stop = PendingIntent.getBroadcast(this, Constants.NOTIFICATION_ID, new Intent(this, PlayerReceiver.class).setAction(STOP_ACTION), PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.notification_stop, "Player Off", stop);
builder.setShowWhen(false);
builder.build();
notification.flags = Notification.DEFAULT_ALL | -Notification.DEFAULT_VIBRATE;
notification.vibrate = null;
notification = builder.build();
startForeground(Constants.NOTIFICATION_ID, notification);