test countdowntimer

This commit is contained in:
Alexander Mahr 2024-10-09 18:26:49 +02:00
parent 9a75e30ae0
commit f6261aebcd

View file

@ -13,6 +13,7 @@ import android.webkit.*;
import android.view.ViewGroup.*;
import android.util.Base64;
import java.lang.Thread;
import android.os.CountDownTimer;
public class ExampleApp extends Activity {
@ -36,11 +37,21 @@ public class ExampleApp extends Activity {
// providing a webpage inline
String unencodedHtml = "<!DOCTYPE html><html><script> window.addEventListener('load',()=>{d=document.createElement('div');d.innerHTML=myJavaScriptInterface.toString()+'JAVASCRIPT works';document.body.appendChild(d);},false);</script><a href='https://html5test.co/'>https://html5test.co/</a><h1> this is html <h1> <h2> this is a h2</h2><img src='https://wald.alexmahr.de/images/rabe.avif'></html>";
String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(),Base64.NO_PADDING);
myWebView.loadData(encodedHtml, "text/html", "base64");
myWebView.loadDataWithBaseURL("https://alexmahr.de/",unencodedHtml, "text/html", "UTF-8",null);
//myWebView.loadData(encodedHtml, "text/html", "base64");
// alternatively this could be to load a website
//myWebView.loadUrl("https://alexmahr.de/ru");
setContentView(myWebView);
myWebView.evaluateJavascript("document.body.innerHTML='all is lost';",null);
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
// mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
myWebView.evaluateJavascript("document.body.innerHTML='SUP "+millisUntilFinished+" all is lost';",null);
}
public void onFinish() {
myWebView.evaluateJavascript("document.body.innerHTML='all is lost';",null);
}
}.start();
}
@JavascriptInterface
public String toString() {