Node-Red Dashboard not loading in Android Webview

Hi, am using the simple code in android to load the Node-Red dashboard in a webview. The dashboard is loading in every other browser except this webview, while the webview is capable of loading other webpage URLs. When i load am getting blank WHITE page. This webview is capable of loading other web pages except nodered dashboard. I have attached my activity code with this, Since this is relativley urgent task, Your quick response would be appreciated :slightly_smiling_face:.

package com.example.myapplication;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.http.SslError;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class WebviewIncogActivity extends AppCompatActivity {
WebView webView;
ProgressDialog progressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview_incog);


        String url=getIntent().getStringExtra("router_ip");
        url="https://"+url+":1880/ui";

        webView=(WebView)findViewById(R.id.webview_incog);
        webView.clearCache(true);
        webView.clearHistory();
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setAppCacheEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webView.getSettings().setAllowFileAccess(true);



        webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                Toast.makeText(getApplicationContext(),"SSl Error",Toast.LENGTH_LONG).show();
                handler.proceed();
           }

            @Override
            public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
                
                Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_LONG).show();

            }

            @Override
            public void onPageFinished(WebView view, String url) {
            
            }
        });

        webView.loadUrl(url);
    }
}

I'm sorry - I have never used Android webview as an application, so i have no advice on this.

Can you see the browser console in webview? If so, it may tell you what is going wrong.

Also, does Angular v1 work with webview? Dashboard uses Angular v1 as a front-end library and it is pretty heavy.

Hi
It should just work.

        mWebView = activity.findViewById(R.id.myWebView);
        mWebView.getSettings().setLoadsImagesAutomatically(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setSupportZoom(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setAllowFileAccess(false);
        mWebView.getSettings().setDomStorageEnabled(true);
        mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
        mWebView.setWebViewClient(new MyBrowser());
        mWebView.setWebChromeClient(new MyCustomWebChromeClient());
        WebView.setWebContentsDebuggingEnabled(false);
        mWebView.setOnScrollChangedCallback((l, t, oldl, oldt) -> appDrawer.visible(false));

this is what i use in my app.

1 Like