WebViewTester - WebView view object tester / demoDennis Lang https://landenlabs.com/index.html
|
The settings fragment manages all of the WebView settings.
The webview fragment is a combination of several controls.
Since the two sections are managed using fragments it is easy to make multiple presentations using different layouts. For exmample, on a wide device (tablet) in Landscape mode the two panels are displayed side-by-side
You can use the WebViewClient to selectively open links either in the webView or via external browser. To achieve this you need to extend the WebViewClient class and implement the shouldOverrideUrlLoading method. The shouldOverrideUrlLoading method is called whenever the WebView tries to navigate to a different URL. If it returns false, the WebView opens the URL itself. The default implementation always returns false, which is why it works in the previous example. public class MyAppWebViewClient extends WebViewClient {// Force links and redirects to open in the WebView instead of in a browser mWebView.setWebViewClient(new WebViewClient());
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if(Uri.parse(url).getHost().endsWith("myHost.com")) { return false; // Special host open in webView } if(Uri.parse(url).getHost().length() == 0) { return false; // Internal page open in webView } // Open in external browser Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); view.getContext().startActivity(intent); return true; }
It is recommended that you enable JavaScript and DOM storage and set the Chrome agent to support the widest variety of websites.