Skip to first unread message

Jussayeh

unread,
Mar 9, 2015, 7:18:31 PM3/9/15
to mitappinv...@googlegroups.com
My app has 5 buttons on  Screen1 that bring you to 5 pages that have two buttons on each page one to  play/pause the video player and the other is a 'back' to bring you back to the previous screen and close the current screen.  I used Tribblehunters multi screen method for this however when I press the back button the the PHONE (not the back button within the app) the app closes out ? Is this normal  or should the back button on the PHONE not just bring you back to the preceding screen?  Here are my blocks .. thanks in advance for any help. I've asked classmates and some say its okay other say its not!
Screen1.png
Meditation Screen.png

Taifun

unread,
Mar 9, 2015, 7:42:24 PM3/9/15
to mitappinv...@googlegroups.com
use the Screen.BackPressed event and add some blocks to go to the screen you like
if you always want to go back to the previous screen, you will have to store that information before going to another screen in TinyDB and read information that again in the Screen.BackPressed event
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

SteveJG

unread,
Mar 9, 2015, 7:42:33 PM3/9/15
to mitappinv...@googlegroups.com
Put this on your Screen1

if you do not put the block in, the app will continue to abort when users accidentally press the button.

Do not put anything in the puzzle piece and it will prevent the app closing when you press the Android device's Back.      or you can use it to open an unopened screen in the app or to present a Notifier message etc.

RegardingTribbleHunter ...nice code, but it only works as advertised one the app in packaged as an apk and installed on the device.  A very good way of avoiding fill up system memory and preventing crashes because Screens, except Screen1 must be closed when leaving them.  Otherwise, the 'app' on each screen will hoard system memory ... until released.


Try it.  Does it work for you? 

What is ok and what is not?    I did not examine the code; if it runs as you want after you add the above block; you are probably ok.

Regards,
Steve



Taifun

unread,
Mar 9, 2015, 7:45:17 PM3/9/15
to mitappinv...@googlegroups.com
btw the "if true" statement is only necessary in procedure goToScreen but not in your button click events...
Taifun

Jussayeh

unread,
Mar 9, 2015, 8:31:14 PM3/9/15
to mitappinv...@googlegroups.com
It's working now! Thanks Taifun and Steve for all your help, I removed the unnecessary 'if true' blocks and I used this block 

newsletter.backpressed :open another screen.Screen1 

and I put it on every screen except Screen1.   

Steve I tried to use it as an empty block on Screen1 but it continued to close when I pressed the back button on the PHONE. 
I've now  tested it by packaging it and installing it and it no longer closes when phone's back button is pressed. Nearly there!
Thanks so much!
backpressed.png
Reply all
Reply to author
Forward
0 new messages