Sudasa Corporation
Sudasa Corporation

Reputation: 3

How to fix loadURL webView in android studio?

hello everyone i have problem to view this url :" https://socindonesia.com " in my webview, can someone help me please.

this is my code:

public class MainActivity extends AppCompatActivity {

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

        WebView webView = (WebView) findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);


        webView.loadUrl("https://socindonesia.com");


    }
}

Upvotes: 0

Views: 579

Answers (2)

ivkil
ivkil

Reputation: 414

As your website requires Web Storage API to run properly, you need to enable it in WebView settings - webView.getSettings().setDomStorageEnabled(true).

Upvotes: 1

android_Muncher
android_Muncher

Reputation: 1057

Make sure you have the internet permission in your manifest file. I think the rest of the code looks good. we also have to make one change to AndroidManifest.xml, adding a line where we request permission to access the Internet:

<uses-permission android:name="android.permission.INTERNET"/>

If we fail to add this permission, the browser will refuse to load pages.

Upvotes: 1

Related Questions