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: 
bosborne
Visitor

Detect when app closed

I'm looking to add some analytics tracking an application and need to track a session start / session end. Session start is easy. But how can I detect when a users closes the app? Do I have any chance to run code before the app actually closes? I'd like to send a session end beacon in that case.
0 Kudos
32 REPLIES 32
RokuChris
Roku Employee
Roku Employee

Re: Detect when app closed

"bosborne" wrote:
I'm looking to add some analytics tracking an application and need to track a session start / session end. Session start is easy. But how can I detect when a users closes the app? Do I have any chance to run code before the app actually closes? I'd like to send a session end beacon in that case.


When the user presses the Home button the channel will exit immediately and return to the Roku home screen. There's no way to detect the Home button.

http://sdkdocs.roku.com/display/sdkdoc/ ... -LevelMenu
0 Kudos
bosborne
Visitor

Re: Detect when app closed

That is what I expected. Thanks
0 Kudos
RokuJoel
Binge Watcher

Re: Detect when app closed

On older devices, firmware 3.1 you might be able to get away with kicking off an http event on msg.isScreenClosed() when the home button is pressed.

- Joel
0 Kudos
bosborne
Visitor

Re: Detect when app closed

Just checking in no this again to make sure support for the home button press hasn't been added? Like giving a little time to "cleanup" certain things.
0 Kudos
tvjay
Channel Surfer

Re: Detect when app closed

How do end a session then if you can't track the home button?
0 Kudos
destruk
Streaming Star

Re: Detect when app closed

Most 'solutions' for this functionality will be ugly clutches - like polling the server at set intervals to 'keep alive'. Most of the time we simply settle for logging button presses or specific activity.
0 Kudos

Re: Detect when app closed

I have ran into a similar situation now, only possible solution I see is a timed event firing to capture event in analytics , but that would cause flooding and complex filtering logic at the part where events are received.
0 Kudos
Rek
Visitor

Re: Detect when app closed

"RokuJoel" wrote:
On older devices, firmware 3.1 you might be able to get away with kicking off an http event on msg.isScreenClosed() when the home button is pressed.

- Joel


Can you offer some insight as to why there is no callback to the application when closing? I would love to have this in my own app, and I'm sure there are many developers who feel the same.
0 Kudos
TheEndless
Channel Surfer

Re: Detect when app closed

"Rek" wrote:
"RokuJoel" wrote:
On older devices, firmware 3.1 you might be able to get away with kicking off an http event on msg.isScreenClosed() when the home button is pressed.

- Joel

Can you offer some insight as to why there is no callback to the application when closing? I would love to have this in my own app, and I'm sure there are many developers who feel the same.

If I recall correctly, the original explanation was that it was to prevent channels from hanging the box indefinitely by including bad code in the close event.
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
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.