Android WebPage showing net::ERR_ACCESS_DENIED while opening Android activity Embedded with with WebPage Tag
I tried to provide permission in Android Manifest.
The following finally worked for me
package com.example.webview01;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
private WebView web;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.webv);
web.setWebViewClient(new WebViewClient());
web.loadUrl("https://www.google.com/");
WebSettings websettings = web.getSettings();
websettings.setJavaScriptEnabled(true);
websettings.setAllowContentAccess(true);
websettings.setAppCacheEnabled(true);
websettings.setDomStorageEnabled(true);
websettings.setUseWideViewPort(true);
}
@Override
public void onBackPressed() {
super.onBackPressed();
if (web.canGoBack()){
web.goBack();
}else{
super.onBackPressed();
}
}
}
The following lines must be included
WebSettings websettings = web.getSettings();
websettings.setJavaScriptEnabled(true);
Uninstall.
Install again.This works for me:
app Uninstall. and Install again. Inside the simulator
It is 100% correct
Uninstall.
Install again.
This solved it for me.
This works for me:
wvMakFukinWalker = findViewById(R.id.wv_mak);
// wvMakFukinWalker is my WebView
// wv_mak the id
WebSettings webSettings = wvMakFukinWalker.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowContentAccess(true);
webSettings.setAppCacheEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setUseWideViewPort(true);
wvMakFukinWalker.setWebViewClient(new WebViewClient());
wvMakFukinWalker.loadUrl("http://yourdomain.com/");
// webSettings.setDomStorageEnabled(true); ==>> I think: this is your solution
Make sure internet permission is given and add android:usesCleartextTraffic="true"
if you use http website.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="in.example.application">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:targetApi="m">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
</application>