Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
bosborne
Level 7

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
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
Level 7

Re: Detect when app closed

That is what I expected. Thanks
0 Kudos
Roku Employee
Roku Employee

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
Level 7

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
Level 7

Re: Detect when app closed

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

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
Level 7

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
Level 7

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