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: 
raxitpandya
Reel Rookie

I want to show Exit dialog box in my app before user leave the app.

Hello 

I want to show Exit dialog box in my app before user leave the app. To resolve the issue, I have follow below link which has all the necessary steps to show dialog box. But in my case same code is not working. 

Link : https://medium.com/@amitdogra70512/confirmation-dialog-on-app-exit-in-roku-b305d91acec8

In my case, dialog box is not getting display and app close directly without waiting for dialog box.

Any suggestions and help are welcome.

Thank you.

 

5 REPLIES 5
ben9000
Streaming Star

Re: I want to show Exit dialog box in my app before user leave the app.

The code provided in the medium blog link seems fine.

Share what you have done to get help.

0 Kudos
raxitpandya
Reel Rookie

Re: I want to show Exit dialog box in my app before user leave the app.

I have used same code. There is no difference in my code for Exit dialog box. 

0 Kudos
renojim
Community Streaming Expert

Re: I want to show Exit dialog box in my app before user leave the app.

I suggest you add print statements to the code to figure out what's going on.  I suspect the key press isn't getting to the onKeyEvent function in MainScene.brs.  For example, add:

print key,press

at the beginning of the onKeyEvent function and:

print msgType

in the event loop.  If you never see "back true" on the debug console you'll know the remote button press never made it to onKeyEvent.

I've found peppering my code with prints is the best way to figure out what SceneGraph is doing.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
RokuBen
Community Moderator
Community Moderator

Re: I want to show Exit dialog box in my app before user leave the app.

Note, this will only catch a user hitting the back button to exit from your main screen.  There's no way to intercept using the home button to return to home screen or using a partner button to launch another channel.

0 Kudos
raxitpandya
Reel Rookie

Re: I want to show Exit dialog box in my app before user leave the app.

Thanks for the reply. in my code, onKeyEvent get executed but i have added the condition 

if press and key = "back" then 

Code inside this condition is not getting executed.

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.