The webview is in the process of loading, but it is failing

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="300" height="150">
Your browser does not support the HTML5 canvas tag.</canvas>
<script src='https://code.jquery.com/jquery-2.1.3.js'></script>
<script>
$(document).ready(function () {

    var canvas = document.getElementById('myCanvas');
    var context = canvas.getContext('2d');

    function Character1(canvas, progress, duration, delay) {
        console.log("c1 " + progress);

        delay = delay || 1;

        var ctx = canvas.getContext('2d');

        debugger;

        if (progress < duration) {

            canvas.strokeStyle = "black";
            ctx.beginPath();
    //ctx.moveTo(3, 1);//original forum code 
            //ctx.lineTo(3, 15 * ((progress + 1)/duration));
    ctx.moveTo(2, 1);
            ctx.lineTo(2 , 20* ((progress + 1) / duration));
           // ctx.moveTo(1, 13);
           // ctx.lineTo(1 , 30* ((progress + 1) / duration));
            ctx.stroke();
            ctx.closePath()

            setTimeout(function () {
                Character1(canvas, progress + 1, duration, delay);
            }, delay);

        } else {
            debugger;
            $(document.body).trigger("Character1Completed");
        }
    }

    function Character2(canvas, progress, duration, delay) {
        console.log("c2");

        delay = delay || 1;

        var ctx = canvas.getContext('2d');

        if (progress < duration) {
            canvas.strokeStyle = "black";
            ctx.beginPath();
            ctx.moveTo(5, 20);//Decrease the 2nd value to move line upwards
            ctx.lineTo(30 * ((progress + 1) / duration), 20);
            ctx.stroke();
            ctx.closePath()

            setTimeout(function () {
                Character2(canvas, progress + 1, duration, delay);
            }, delay);
        }
        else {
            
            $(document.body).trigger("Character2Completed");
        }
    }

    function Character3(canvas, progress, duration, delay) {
        console.log("c3");

        delay = delay || 1;

        var ctx = canvas.getContext('2d');

        if (progress < duration) {

            var x = 23;//Decrease/increase to move the arc right/left side
            var y = 12;//Decrease to move the arc up
            var radius = 10;
            var startAngle = .3 * Math.PI;
            var endAngle = -1.3 * Math.PI;
            var counterClockwise = false;

            ctx.beginPath();
            ctx.arc(x, y, radius, startAngle, endAngle * ((progress + 1) / duration), true);
            ctx.lineWidth = 1;
            ctx.stroke();

            setTimeout(function () {
                Character3(canvas, progress + 1, duration, delay);
            }, delay);
        }
        else {
            $(document.body).trigger("Character3Completed");
        }
    }

    $(document.body).on("Character1Completed", function (e) {
        console.log("Starting Character 2");

        Character2(canvas, 0, 30, 33);
    });

  /*  $(document.body).on("Character2Completed", function (e) {
        console.log("Starting Character 3");

        Character3(canvas, 0, 30, 33);
    });*/

    $(document.body).on("Character3Completed", function (e) {
        console.log("Completed Drawing!");
    });

    // Start Drawing
    Character1(canvas, 0, 30, 33);

});
</script>
</body>
</html>

This is a snippet of my HTML code used for drawing shapes on a canvas element and triggering completion events.

            WebView wv;  
            wv = (WebView) findViewById(R.id.mybrowser1);  
            wv.loadUrl("file:///android_asset/www/ta.html");
            wv.getSettings().setJavaScriptEnabled(true);
            wv.setBackgroundColor(Color.TRANSPARENT);

When attempting to load this HTML code in an Android WebView, it seems to load successfully but remains invisible on the screen. The following error message is displayed:

In ResourceHandle::create newHandle -> Blocked Failure

Looking at the logcat, the aforementioned error is reported. I'm unsure about what might be causing this issue.

Trying to display the webpage without any user interaction also results in a message stating:

Your browser does not support the HTML5 canvas tag

Answer №1

After tweaking these settings and implementing them into my HTML page, everything ran smoothly. Check out the outcome: https://i.sstatic.net/dYjrn.png

 WebView mWebView = (WebView) findViewById(R.id.webview);
    WebViewClient wvClient = new WebViewClient();
    mWebView.setWebViewClient(wvClient);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setSaveFormData(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDefaultTextEncodingName("utf-8");
    mWebView.loadUrl("http://192.168.1.42/testing123");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking to modify the color of the post's <h1> heading if there is no featured image assigned to it

While working on my WordPress blog and browsing various other WordPress blogs, I noticed that setting a featured image can really make a difference in grabbing the reader's attention. However, when a featured image is not set, I have a default backgro ...

Unable to locate the element within a component using Cypress

I need help locating the dropdown arrow. I tried using the Cypress command cy.get('.dropdown-arrow').click() but it's throwing an error saying element not found. Below is the code snippet: <widgets-bms-scoreboard> <div class=&q ...

Search MongoDB to find, update, and validate any empty fields in the body

I'm currently working on updating a user's profile information, but I'm facing a problem with checking for empty values before proceeding with the update. The code I've written so far is not displaying error messages and is preventing m ...

Retrieve data from a jQuery AJAX request and perform further jQuery actions upon its successful completion

I am trying to figure out how to use jQuery AJAX to duplicate a background image and then return information back to the original page. When the '#dupBtn' is clicked, the following AJAX is sent... //DUPLICATE BACKGROUND $('#dupBtn&apo ...

Trigger an alert message upon loading the HTML page with search text

I need to search for specific text on a webpage and receive an alert if the text is found. <script type='text/javascript'> window.onload = function() { if ((document.documentElement.textContent || document.documentElement.innerText ...

ArangoDB's graph maxDepth setting causing excessive iterations

I am working on creating a substantial social network graph using ArangoDB. The database currently contains approximately 35,000 vertices connected by around 150,000 edges. Considering the extensive amount of data, I was looking to display only a portion ...

Issues with Cordova and JQuery ajax functionality not operating as expected

I am facing an issue with implementing AJAX functionality in my Cordova app (CLI 6.3.1) on Visual Studio 2017. It works fine on the emulator, but I encounter a connection error when installing it on a mobile phone. I have already included CSP as shown bel ...

BlockUI - Uncaught error: The object does not contain the method 'blockUI'

Trying to implement the blockUI jQuery Plugin, I have added the necessary libraries in this way; <script src="http://malsup.com/jquery/block/jquery.blockUI.1.33.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery ...

Renaming a File using renameTo alters the file's contents

File dir = new File(getFilesDir(), "dir1"); dir.renameTo(new File(getFilesDir(), "dir2"); Log.d("Number of files:", dir.listFiles().length); If there are 5 files in /dir1/, the first code snippet will output 0. However, when the code is modified as follow ...

Tips for sending props to Material UI components

Hey there! I'm currently working on a progressbar component that utilizes animations to animate the progress. I've styled the component using Material UI classes and integrated it into another component where I pass props to customize the progres ...

Android: Prompt for WRITE_EXTERNAL_STORAGE permission is not displayed

My Android app requires specific permissions to function properly: ACCESS_FINE_LOCATION, ACCESS_WIFI_STATE, WRITE_EXTERNAL_STORAGE, RECORD_AUDIO Here is an excerpt from my AndroidManifest.xml file: <?xml version="1.0" encoding="utf-8"?> <manife ...

How can I pass a value to a javascript function when a button in asp.net is clicked?

For the client side code, I have written the following: <script> function initialize(x, y) { alert(x); alert(y); var mapProp = { center: new google.maps.LatLng(x, y), zoom: 7, mapTy ...

Ways to extract specific HTML from a jQuery element

When fetching html from a website, how can I extract specific html content instead of getting all of it? I have attempted the following method: Before appending data to the target below container.html(data); I would like to perform something like data.f ...

Leveraging Webworkers in an Angular application for efficient data caching with service workers in the Angular-CLI

I am looking to run a function in the background using a worker, with data coming from an HTTP request. Currently, I have a mock calculation (e.data[0] * e.data[1] * xhrData.arr[3]) in place, but I plan to replace it with a function that returns the actual ...

adjusting sizes of google maps v2 on android platform

My goal is to develop an animation that expands the MapFragment when the user drags the screen downwards. While the physics aspect works fine with Google Maps v1, I've encountered a delay in re-drawing the updated map after upgrading. Here is how I&ap ...

After clicking on a link, there will be a brief pause before the page transition occurs, once

I've been looking for solutions to similar problems, but none of them have worked for me. Here's my issue: I have a few links in the header of my website (such as about, portfolio, etc.) and I have a JavaScript animation that triggers when an &l ...

Comparing NodeJS equivalents to window.location and window.pathname

Can anyone tell me how to achieve the same functionality as window.location.protocol and window.location.host in NodeJS/ExpressJS? I need to redirect the URL back to my website using a third-party API. Any advice is appreciated! ...

What is the method for entering a value in Code Mirror using Selenium WebDriver?

Struggling with inserting input values into Code Mirror, which is HTML code. Any assistance would be greatly appreciated! This is what I have been attempting so far (but I need to insert values on each line of Code Mirror) JavascriptExecutor js = (Javas ...

The palindrome checking function is malfunctioning and needs to be fixed

I have attempted to create a function to determine if a number is a palindrome, but it seems to be malfunctioning. The concept is simple - splitting the number into two halves, comparing them, and reversing one half to check for symmetry. function palin ...

Having Trouble Redirecting to Another Page from My Ionic Framework Controller?

Struggling to figure out why my app isn't switching to another page when clicking in my controller. Any help or pointers on what I might be missing or doing wrong would be greatly appreciated! Here's the code snippet from my app.js file: $s ...