현재 lg g5기기 테스트결과 강제로 소리나오는거까지는 완료했지만 s8기종에서는 벨소리 모드여야만 나옵니다.
제가 하고싶은건 무음이든 진동이든 특정플래그 전달시 알람이 강제로 울렸으면 좋겠고,
다른플래그를 전송하면 알람이 멈췄으면좋겠는데 이부분이 잘해결되지않습니다.
해당부분 코드입니다.
// 알림 builder 설정
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
Drawable thumb = getResources().getDrawable(R.drawable.ic_backpack);
Bitmap bmpOrg = ((BitmapDrawable) thumb).getBitmap();
notificationBuilder
.setSmallIcon(R.drawable.push_icon)
.setColor(getResources().getColor(R.color.red))
.setColorized(true)
.setLargeIcon(bmpOrg)
.setContentTitle(title)
.setContentText(contents)
.setAutoCancel(true)
.setSound(defaultSoundUri).setLights(000000255, 500, 2000)
.setPriority(PRIORITY_MAX)
.setContentIntent(pendingIntent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(contents)
.setBigContentTitle(title)
.setSummaryText("알림 메세지")
);
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
if(flag >= 1) {
// flag 1이상일때 강제 알림
r.play();
}
if (flag == 0){
System.out.println("5465");
r.stop();
}
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakelock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "powerenglish:TAG");
wakelock.acquire(5000);