Forum Discussion

SamZ's avatar
SamZ
Visitor
14 years ago

Closing the app when you are several screens deep

I'd like to close my app/channel in some cases, i.e. when I detect an abuse after showing an error message! In some cases I might be several levels/screens deep and I don't keep global references to all my open screens. So when I wanted to exit the app, some of them stayed open! I didn't find any references to exiting the program! I appreciate your help.

10 Replies

  • Does the END statement still apply to devices with newer firmware (4.8-5)? I cannot forcibly make a channel exit with a Roku 3 running 5.0.7070

    I need the channel to exit once the device is no longer linked to an account.
  • "dustinhood" wrote:
    Does the END statement still apply to devices with newer firmware (4.8-5)? I cannot forcibly make a channel exit with a Roku 3 running 5.0.7070

    I need the channel to exit once the device is no longer linked to an account.

    If nothing else works, you can send yourself a keypress/Home ECP command.

    ipaddrs = CreateObject("roDeviceInfo").GetIPAddrs()
    if ipaddrs.eth0 <> invalid then
    ipaddr = ipaddrs.eth0
    end if
    if ipaddrs.eth1 <> invalid then
    ipaddr = ipaddrs.eth1
    end if
    xfer = CreateObject("roURLTransfer")
    url = "http://"+ipaddr+":8060/keypress/Home"
    xfer.SetUrl(url)
    xfer.PostFromString("")
    Credits to renojim for the brightscript code: viewtopic.php?f=34&t=55236#p375957
  • "dustinhood" wrote:
    Does the END statement still apply to devices with newer firmware (4.8-5)? I cannot forcibly make a channel exit with a Roku 3 running 5.0.7070

    I need the channel to exit once the device is no longer linked to an account.

    I just tested on 5.0b7070 and End worked for me.

    I don't know if it makes a difference, but I add the following to the same file as RunUserInterface, and just call ExitUserInterface anytime I need to close the channel programmatically, so technically I'm calling End from the global context instead of local:
    Sub ExitUserInterface()
    End
    End Sub
  • "TheEndless" wrote:

    Sub ExitUserInterface()
    End
    End Sub


    Just tried above with no luck. Does it matter where/how ExitUserInterface() is called?
  • It shouldn't. I use it exactly how it sounds like you're wanting to. As soon as the user chooses to unlink their box, I exit the channel.

    ShowMessageBox("Account Unlinked", "Your account has been unlinked.  The channel will now close.  Please relaunch it to link your player again.")
    ExitUserInterface()
  • For some reason this just won't work...


    Sub ExitUserInterface()
    End
    End Sub


    I've tried using the following workaround, but this doesn't appear to work except for on my newest Roku running firmware 5+.


    Function forceExitChannel() As Dynamic

    ipaddrs = CreateObject("roDeviceInfo").GetIPAddrs()
    if ipaddrs.eth0 <> invalid then
    ipaddr = ipaddrs.eth0
    end if
    if ipaddrs.eth1 <> invalid then
    ipaddr = ipaddrs.eth1
    end if
    xfer = CreateObject("roURLTransfer")
    url = "http://"+ipaddr+":8060/keypress/Home"
    xfer.SetUrl(url)
    xfer.PostFromString("")

    End Function


    Any other suggestions?
  • Well, the normal approach is to just return through your screens until you return from your entry point. Make each of the screen's functions return a special value that is checked by the caller, which then returns a special value to its caller, etc.

    The stop statement will terminate your channel, but this is not a recommended approach. It makes your channel appear to have crashed. I don't think this actually has any detrimental effect right now but it's not recommended.

    --Mark