Muhammad Arslan
Muhammad Arslan

Reputation: 1257

webview in Android Studio with error ""webpage could not be loaded because net:: ERR_ACCESS_DENIED""

In my previous project I've implemented a review that works fine.. but when I created a new webview and implement these features then they works like this.

The error is stated that "webpage could not be loaded because of net:: ERR_ACCESS_DENIED"

my main code:

public class MainActivity extends AppCompatActivity {
    WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setBlockNetworkLoads (false);
        webView.loadUrl("http://www.dailytennistips.com");
        Log.e("Link","http://www.dailytennistips.com");
        webView.setWebViewClient(new WebViewClient());

    }

xml file


    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout_editor_absoluteX="221dp"
        tools:layout_editor_absoluteY="243dp" />

Upvotes: 0

Views: 4659

Answers (1)

Squti
Squti

Reputation: 4487

It's because your domain doesn't use SSL. Add android:usesCleartextTraffic="true" to your manifest application tag like so:

<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

Upvotes: 1

Related Questions