0
알림 빌더를 사용하고 소리, 진동 및 빛을 원하는 Im. 진동과 빛은 잘 작동하지만 소리가 나지 않습니다. 나는 여기에서 많은 해결책을 시도했지만 em의 대부분은 deprecated 버전을위한 것이다. 아래 코드에서 은 무엇을하고 있는지 볼 수 있습니다. 나는 alamsound와 소리를 시도했지만 아무도 효과가 없었습니다. 허가가 필요합니까?Android 알림 빌더 사운드
public void createTestNotification(){
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
long[] vibrate = { 0, 100, 200, 300 };
NotificationManager nm= (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
Uri sound = Uri.parse("android.resource://com.uks.uksnavigation/" + R.raw.notification);
Intent intent = new Intent(this.getActivity(), MainActivity.class);
intent.setAction("nachricht");
PendingIntent pIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);
Notification.Builder mBuilder =
new Notification.Builder(getActivity())
.setContentIntent(pIntent)
.setSmallIcon(R.drawable.ic_stat_mail_aktiv)
.setContentTitle("New Message")
.setContentText("Nachrichten text text text")
.setSound(sound)
.setVibrate(vibrate)
.setLights(Color.BLUE, 500, 500);
nm.notify(1, mBuilder.build());
}