Today I made WebView for both webpages I had had before (board.samd.ch and moodle.samd.ch). The difficulty described in the WebView post arose this time as well. Now, after some debugging of the code, all local links open directly in the app while global links open in the browser. Another difficulty I faced was that WebView didn’t allow to go to the previous page, but kept returning me right back to the app.
So my solution was to check if it is possible to go back to the previous webpage. When it is impossible, the user would be redirected to the app. See the code below.
@Override
public void onBackPressed() {
if (view.canGoBack()) {
view.goBack();
} else {
super.onBackPressed();
}
}
It was also important to remember to make view a global variable, adding WebView view at the beginning.