2017-09-17 14 views
10

पर काम नहीं कर रहा है मेरे पास निम्न कोड है लेकिन हर बार जब मैं सिर्फ डिफ़ॉल्ट एंड्रॉइड ध्वनि सुनता हूं।एंड्रॉइड 8 नोटिफिकेशन सेट

 // 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); 

यह मेरा ध्वनि pablomonteserin.es/aperturaabductores.wav

+0

कोई भी वास्तव में नहीं? – Ricardo

+0

परीक्षण किया गया। एम्यूलेटर में काम करना –

+0

मेरे एमुलेटर और डिवाइस में काम नहीं कर रहा है। क्या आपने एंड्रॉइड 8 पर परीक्षण किया था? कृपया ध्यान दें कि मैं एक कस्टम ध्वनि लोड करना चाहता हूं। – Ricardo

उत्तर

2

मैं अपने ध्वनि फ़ाइल और मेरा के बीच अंतर को देखने के लिए करने की कोशिश की है। मैंने ऑडैसिटी सॉफ्टवेयर का इस्तेमाल किया। आपकी ध्वनि फ़ाइल में नमूना दर 22050 हर्ट्ज है जबकि ध्वनि फ़ाइलों का उपयोग 44100Hz पर किया जाता है। तो मैंने आपकी ध्वनि फ़ाइल नमूना दर 44100Hz में परिवर्तित की और अधिसूचना ध्वनि के रूप में उपयोग किया। अब यह काम कर रहा है।

समस्या ध्वनि फ़ाइल के साथ है। हो सकता है कि यह एंड्रॉइड ओ में नया बदलाव हो क्योंकि यह पुराने एंड्रॉइड संस्करण पर ठीक काम कर रहा है।

यह कैसे है पुन: नमूना- enter image description here

संबंधित मुद्दे