From bf535476ecdce86ec20806078f0c25186af4249a Mon Sep 17 00:00:00 2001 From: Alexander Mahr Date: Wed, 9 Oct 2024 09:25:39 +0200 Subject: [PATCH] add to the Webview content, link and javascript test --- apk/src/app/example/ExampleApp.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apk/src/app/example/ExampleApp.java b/apk/src/app/example/ExampleApp.java index 87da4dd..1f9632c 100644 --- a/apk/src/app/example/ExampleApp.java +++ b/apk/src/app/example/ExampleApp.java @@ -17,15 +17,23 @@ public class ExampleApp extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // this removes the title bar (a ~1cm big strip at the top of the app showing its name + this.requestWindowFeature(Window.FEATURE_NO_TITLE); + // we create the webview (at least on the android 14 that is a webview that features avif + websockets etc....) WebView myWebView = new WebView(this);//activityContext); + // we create a webview (there is also setwebviewclient-vs-setwebchromeclient WebViewClient myWebViewClient= new WebViewClient(); myWebView.setWebViewClient(myWebViewClient); - String unencodedHtml = "https://html5test.co/

this is html

this is a h2

"; - String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(),Base64.NO_PADDING); + // to setup settings WebSettings myWebSettings = myWebView.getSettings(); myWebSettings.setBuiltInZoomControls(true); + myWebSettings.setDisplayZoomControls(false); myWebSettings.setJavaScriptEnabled(true); + // providing a webpage inline + String unencodedHtml = "https://html5test.co/

this is html

this is a h2

"; + String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(),Base64.NO_PADDING); myWebView.loadData(encodedHtml, "text/html", "base64"); + // alternatively this could be to load a website //myWebView.loadUrl("https://alexmahr.de/ru"); setContentView(myWebView); }