Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
SamZ
Visitor

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.
0 Kudos
10 REPLIES 10
RokuJoel
Binge Watcher

Re: Closing the app when you are several screens deep

usually the end statement will kill your channel.

- Joel
0 Kudos
dustinhood
Visitor

Re: Closing the app when you are several screens deep

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.
0 Kudos
gonzotek
Visitor

Re: Closing the app when you are several screens deep

"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
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
0 Kudos
dustinhood
Visitor

Re: Closing the app when you are several screens deep

Thanks will give that I try for now
0 Kudos
TheEndless
Channel Surfer

Re: Closing the app when you are several screens deep

"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
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
dustinhood
Visitor

Re: Closing the app when you are several screens deep

"TheEndless" wrote:

Sub ExitUserInterface()
End
End Sub


Just tried above with no luck. Does it matter where/how ExitUserInterface() is called?
0 Kudos
TheEndless
Channel Surfer

Re: Closing the app when you are several screens deep

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()
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
dustinhood
Visitor

Re: Closing the app when you are several screens deep

Thanks, I will experiment more with it tomorrow.
0 Kudos
dustinhood
Visitor

Re: Closing the app when you are several screens deep

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?
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.