net::ERR_ACCESS_DENIED Android error while opening WebPage in Android Activity

后端 未结 7 698
青春惊慌失措
青春惊慌失措 2021-01-12 08:38

Android WebPage showing net::ERR_ACCESS_DENIED while opening Android activity Embedded with with WebPage Tag

I tried to provide permission in Android Manifest.

相关标签:
7条回答
  • 2021-01-12 09:08

    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);
    
    0 讨论(0)
  • 2021-01-12 09:09

    Uninstall.

    Install again.This works for me:

    0 讨论(0)
  • 2021-01-12 09:15

    app Uninstall. and Install again. Inside the simulator

    It is 100% correct

    0 讨论(0)
  • 2021-01-12 09:16

    Uninstall.

    Install again.

    This solved it for me.

    0 讨论(0)
  • 2021-01-12 09:20

    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

    0 讨论(0)
  • 2021-01-12 09:24

    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>
    

    0 讨论(0)
提交回复
热议问题