I am using vertical arrangements to simulate different screens. Attempting to use the Device Back Button to call the WEBVIEWER.GOBACK to display previous sites

I am using vertical arrangements to simulate different screens. Attempting to use the Device Back Button to call the WEBVIEWER.GOBACK to display previous sites.

Hello. I have created an app for my kids’ soccer club. I am practically using this app as a web browser for the soccer club’s website. I created a horizontal arrangement (placed at the top of the screen) with buttons for each of the web page’s tabs. When I click on any of the buttons, a PROCEDURE that hides all of the buttons and web viewers is activated, and only the desired button and web viewer are displayed. The code as is works beautifully as intended.

However, when I press the DEVICE’S BACK BUTTON, the app closes. What I would like to happen is for the app to reset the web viewer to previous sites viewed. After doing some research, it appears that the best solution for my situation is to use the “WHEN SCREEN1. BACKPRESSED” block. However, I don’t know how to properly set these up (IMAGE 3). Any help would be greatly appreciate it.

The app is already in the Play Store: https://play.google.com/store/apps/details?id=appinventor.ai_maestro_javier_ortega.DCSCApp_V1_0

You will need to do a text comparison of the actual URLs.

Think again about using the Back Button, that’s not it’s intended use. Far better to provide your own controls.

This was an issue but it was resolved a couple of days ago.
As for the blocks I recommend something like this:

1 Like

I am using 16 WEB VIEWERS in my app. How would this block arrangement work so that it applies to ANY WEB VIEWER. Please refer to image #3.

Hello Chris. Since the web viewers display pages that are rather long, I tried to stay away from inserting buttons that users would need to scroll down to find. I am interested in your “text comparison of the actual urls” solution to this. How would it look like given that I am using 16 different WEB VIEWERS?

Wow! Why not just use 1?

Consider putting the buttons at the top, same as a regular browser.

Can you tell us why you need more than one Web View component?

2 Likes

I thought each web viewer has to be assigned its HOME URL. What I did was create 16 vertical arrangements that include a Web Viewer. When the button for HOME is pressed, the HOME VERTICAL ARRANGEMENT becomes visible (which includes the web viewer with its assigned URL) and the other 15 VERTICAL ARRANGEMENTS are hidden. When the button for CONTACT US is pressed, the CONTACT US VERTICAL ARRANGEMENT becomes visible (which includes the web viewer with its assigned URL) and the other 15 VERTICAL ARRANGEMENTS are hidden. Maybe there is an easier way to do this, but that’s what I came up with. Is there a better way of doing this?

1 Like

When I tried to follow your instructions, these are the blocks that show up in my screen:

6

You can use 1 webviewer and just change the url as needed with this block:
Screenshot_20200415-140044_Chrome

Thank you Chris and Ken, after reading both of your responses, I completely abandoned my original blocks with a bunch of vertical arrangements and web viewers, which simplified my code. Now, I am only using one WebViewer with one Vertical Arrangement. With this set up I was able to apply your recommended “When Screen1.BackPressed” block with the recommended “Compare Texts” and “Call WebViewer1.GoBack” blocks. It now works exactly how I wanted it to work. Thank you very much! I learned a lot!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.