Error: Permission Required

Hi,

here is the error i have when i try a background process on my wf

exactly the same code as the other wf i did which have no issue

i did put the "BackGround" Permission and Background annotation...

Error: Permission Required
Details: Module 'Toybox.WatchUi' not available to 'Background'
Stack: 
  - onBackgroundData() at D:\eclipse-workspace\SHN A_TcxD\source\SHNA_TcxDApp.mc:119 0x1000071d

many thanks....

  • I'd expect to see this message if you were trying to use the WatchUi module from code running in a Background application context. Background code can't access the WatchUi module.

    The error message seems to indicate that the onBackgroundData method is being called. I think it is probably safe to assume this is AppBase.onBackgroundData() given the source file referenced in the stack trace. I'm not sure why this function would be getting called in a Background context. I would expect this function to get called when the app is loaded in a Foreground context. Maybe you can shed some light?

    Regardless, I'm guessing that you are trying to use WatchUi.loadResource(). If your code is indeed running in a Background context, you should be able to use Application.loadResource() instead (you may want to do a has check as this function was added in ConnectIQ 3.1.0). If you know that you are executing as a Foreground app, you should be able to use WatchUi.

  • hi actually i cahnge some stuff and know i have:

    Error: Permission Required
    Details: Module 'Toybox.WatchUi' not available to 'Background'
    Stack: 
      - receiveWeather() at D:\eclipse-workspace\SHN A_TcxD\source\SHNatxdBG.mc:94 0x100006dc 

    this line stands for the Bg.exit

    in my bg process, there is no access to the Toybox.WatchUi

    and i've been using it for aa while for other wf, no issue with them.

    even if i delet all background code,

    only put Background permission "on" and background annotation, i have this error also

  • ok many thanks, I found what was wrong thanks to you,

    i just found that I put (i don't know why)

    WatchUi.loadResource() in root var instead of in initialize...

    Many Thanks