Android Question granturipermission error on internal storage in NB6 customSound

Discussion in 'Android Questions' started by Azam Memon, Apr 26, 2019.

  1. Azam Memon

    Azam Memon Member Licensed User

    I have obtained URI of a sound using RingTone Manager for NB6 custom sound, the URI of sound is:

    Code:
    content://media/internal/audio/media/30
    When I try

    Code:
    n.CustomSound("content://media/internal/audio/media/30")
    I get the following exception.

    Code:
    (RuntimeException) java.lang.RuntimeException: Method: grantUriPermission not matched.
    and when I try to use:

    Code:
    Dim u As Uri
    u.Parse(
    "content://media/internal/audio/media/30")
    n.CustomSound(u)
    I do not get any Exception but it also plays default sound, instead of the selected one.

    however, the same URI works fine with RingtoneManager and plays the sound. Please suggest any workaround for this issue.

    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This looks correct. Try to change the channel id. Once you plan a notification with a specific channel id the sound cannot be changed.
     
    Azam Memon likes this.
  3. Azam Memon

    Azam Memon Member Licensed User

    So do I need to change channel id every time the user changes notification sound?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Yes.
     
    Azam Memon likes this.
  5. wes58

    wes58 Active Member Licensed User

    No, you don't have to, if the user changes the sound on the application notification settings screen. That what is behind google's idea with notification channels. Once you create the channel with specific settings, only the user can change those settings - i.e. change the sound, change vibration or change whether they want to have notification enabled or not. You should respect user's choice of notification sound.You should use the same channel id.
     
  6. Azam Memon

    Azam Memon Member Licensed User

    How a user can change these settings? I don't want to change message tone for all applications, all i want is to change sound of notification for my own application.

    The only way to do it is to set notification sound as:

    Where n is NB6

    And when I set a specific channel id and a specific sound, then even if I change the sound with keeping same channel id, sound of notification doesn't change.

    Can you please suggest workaround for that? With example code?
     
  7. Azam Memon

    Azam Memon Member Licensed User

    Thanks Erel, this worked.
     
  8. wes58

    wes58 Active Member Licensed User

    Have a look in this thread https://www.b4x.com/android/forum/threads/nb6-class-additional-functions.104319/
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice