How to load main domain urls in a Android WebView App with subdomain as base url?-ThrowExceptions

Exception or error:

I try to load a subdomain into my WebView. This works fine, in this landing page I have some Links to my main page like imprint, about team…. The Problem is that die Links not working. How I Can fix that?

e.g.

Sub domain https://landing.mypage.com
Has an imprint linked to
Main domain https://mypage.com/imprint

My Code

    String baseUrl = "https://landing.mypage.com";
    WebView myWebView = new WebView(getApplicationContext());
    setContentView(myWebView);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setAllowFileAccess(true);
    webSettings.setAllowContentAccess(true);
    webSettings.setAllowFileAccessFromFileURLs(true);
    webSettings.setAllowUniversalAccessFromFileURLs(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setSupportMultipleWindows(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setJavaScriptEnabled(true);

    myWebView.loadUrl(baseUrl);
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *