2017-09-17 25 views
10

Aşağıdaki kod var ama her zaman sadece varsayılan android sesi duyuyorum.Android 8 bildirimleri setSound çalışmıyor

 // create channel 
     NotificationChannel channel = new NotificationChannel(ANDROID_CHANNEL_ID, 
       ANDROID_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); 
     // Sets whether notifications posted to this channel should display notification lights 
     channel.enableLights(true); 
     // Sets whether notification posted to this channel should vibrate. 
     channel.enableVibration(true); 
     // Sets the notification light color for notifications posted to this channel 
     channel.setLightColor(Color.GREEN); 
     // Sets whether notifications posted to this channel appear on the lockscreen or not 
     //channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); 
     channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); 

     Uri uri = Uri.parse("android.resource://"+this.getPackageName()+"/" + R.raw.aperturaabductores); 

     AudioAttributes att = new AudioAttributes.Builder() 
       .setUsage(AudioAttributes.USAGE_NOTIFICATION) 
       .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) 
       .build(); 
     channel.setSound(uri,att); 

Bu pablomonteserin.es/aperturaabductores.wav

+0

Kimse resample- için nasıl? – Ricardo

+0

Test edildi. emülatörde çalışıyor. –

+0

Benim emülatörümde ve aygıtımda çalışmıyor. Android 8'de test ettin mi? Lütfen özel bir ses yüklemek istiyorum. – Ricardo

cevap

2

ben ses dosyası ve mayın arasındaki farkı görmek çalıştı benim sesidir. Audacity yazılımı kullandım. Ses dosyası kullandığım ses dosyaları 44100Hz'de örneklenirken ses dosyanızın örnekleme hızı 22050Hz'dir. Bu yüzden ses dosyası örnekleme oranınızı 44100Hz'e dönüştürdüm ve bunu bildirim sesi olarak kullandım. Şimdi çalışıyor.

Sorun, ses dosyasında. Eski Android sürümünde iyi çalıştığı için Android'deki yeni değişiklik olabilir.

Bu gerçekten enter image description here

İlgili konular