how to function phone back button to go to previous web page

976 views
Skip to first unread message

GANESH BARVE

unread,
Apr 30, 2017, 6:27:12 AM4/30/17
to MIT App Inventor Forum
Hi all,

i am converting my web page into a app by just adding webview.

How to function my phone back button to go to previous web page


SteveJG

unread,
Apr 30, 2017, 9:13:51 AM4/30/17
to MIT App Inventor Forum
Use the Screen.BackPressed event handler  and be aware of

these properties in the WebVIewer     What have you tried?

FollowLinks
Determines whether to follow links when they are tapped in the WebViewer. If you follow links, you can use GoBack and GoForward to navigate the browser history.
Height
HomeUrl
URL of the page the WebViewer should initially open to. Setting this will load the page.
IgnoreSslError
Determine whether or not to ignore SSL errors. Set to true to ignore errors. Use this to accept self signed certificates from websites.
PromptforPermission
If True, then prompt the user of the WebView to give permission to access the geolocation API. If False, then assume permission is granted.
UsesLocation (designer only)
Whether or not to give the application permission to use the Javascript geolocation API. This property is available only in the designer.
Visible
Specifies whether the component should be visible on the screen. Value is true if the component is showing and false if hidden.
WebViewString
Gets the WebView's String, which is viewable through Javascript in the WebView as the window.AppInventor object
Width

Events

none

Methods

boolean CanGoBack()
Returns true if the WebViewer can go back in the history list.
boolean CanGoForward()
Returns true if the WebViewer can go forward in the history list.
ClearCaches()
Clear the WebViewer caches
ClearLocations()
Clear stored location permissions.
GoBack()
Go back to the previous page in the history list. Does nothing if there is no previous page.
GoForward()
Go forward to the next page in the history list. Does nothing if there is no next page.

Nico Marikucza

unread,
Apr 30, 2017, 1:40:43 PM4/30/17
to MIT App Inventor Forum
Thank you Steve. Here is an example:


Nico

GANESH BARVE

unread,
May 3, 2017, 1:42:34 PM5/3/17
to MIT App Inventor Forum
Hi All,

Thanks for your suggestion,it looks pretty good.

My requirement is 

if i am in home URL suppose i pressed back button.it should close application.other wise it should load previous web page.

How to do this??

Regards,
Ganesh Barve 

SteveJG

unread,
May 3, 2017, 3:49:10 PM5/3/17
to mitappinv...@googlegroups.com
You do it by learning how to program in App Inventor Ganesh.

What you want to do is discussed here

but not specifically.

Try some blocks, if you are unsuccessful, show us what you tried and someone will provide specific advice.

We want you to have fun with App Inventor and learn to program.  Perhaps before you finish your back button exercise,  you should start reading and use some resources to help you learn to use the AI2 tools  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .


Do some tutorials, then start building your project.  If you show us what you have done by providing an image of your blocks here, someone will give you specific advice.

Regards,
Steve

Nico Marikucza

unread,
May 7, 2017, 11:15:14 AM5/7/17
to MIT App Inventor Forum
Here a 2nd example:








Nico

Akshay

unread,
May 7, 2017, 1:11:11 PM5/7/17
to MIT App Inventor Forum

This should help:


Make sure that the FollowLinks property of the WebViewer from the Properties Pane is checked.



As Steve said, you should try this on your own. 


We want you to have fun with App Inventor and learn to program.

Regards. 
Reply all
Reply to author
Forward
0 new messages