내 알림이 올 때 기본 진동 및 소리 알림을 받으려고 노력하고 있지만 지금까지는 운이 없습니다. 기본값을 설정하는 방법과 관련이 있다고 생각하지만 어떻게 고칠 지 모르겠습니다. 이견있는 사람?
public void connectedNotify() {
Integer mId = 0;
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_notify)
.setContentTitle("Device Connected")
.setContentText("Click to monitor");
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(getApplicationContext(),
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
mBuilder.setOngoing(true);
Notification note = mBuilder.build();
note.defaults |= Notification.DEFAULT_VIBRATE;
note.defaults |= Notification.DEFAULT_SOUND;
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(mId, note);
}
이 스레드에서 솔루션을 적용 할 수 있고 알림에 여전히 진동이없는 사람에게 먼저 알림 채널의 진동을 활성화해야 할 수 있습니다. 이것을보세요 : stackoverflow.com/a/47646166/8551764
—
Mostafa Arian Nejad
android.permission.VIBRATEAndroidManifest.xml에서 누락 되었습니다.