0

My webview only showing white screen son specific url. (It's working with for ex. google.com)

package com.cemcebi.beyanname;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("https://*****/");
    }
}

Does anyone have any idea that why it's not opening.

cemthecebi
  • 104
  • 13

2 Answers2

2

imageI ran your code in my app and voila it worked.

First add the following line in your manifest file.

android:cleartextTrafficPermitted="true"

Now change the link from https to http and it works perfectly.

Let me know you why I did this..!! When the original link is compiled I got a error like handshake failed SSL certificate returned -1. So I guess it mean the website has some issues. So try using this.

Hope it helps.

0

in my case, adding this fixed it:

            WebSettings webSettings = webView.getSettings();
            webSettings.setJavaScriptEnabled(true);

            webSettings.setDatabaseEnabled(true);
            webSettings.setDomStorageEnabled(true);
            String databasePath = webView.getContext().getDir("databases", Context.MODE_PRIVATE).getPath();
            webSettings.setDatabasePath(databasePath);
alex
  • 41
  • 3