3

The app does not connect to the internet. I have

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

in my manifest and I checked the other applications on the emulator for example youtube and google search works but the application isn't able to load the page. This is my main java file.

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;


public class MainActivity extends Activity {


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

        WebView myWebview ;
        myWebview  = (WebView) this.findViewById(R.id.webz);

        myWebview.loadUrl("https://en.wikipedia.org/");

    }

}

and this is my main activity

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.hoda.myapplication.MainActivity">



    <WebView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/webz"></WebView>
</android.support.constraint.ConstraintLayout>

this is the error i get

[ERROR:gl_surface_egl.cc(289)] eglChooseConfig failed with error EGL_SUCCESS
helpmeplease
  • 101
  • 1
  • 1
  • 9
  • 1
    restart the emulator as suggested here [link](https://stackoverflow.com/questions/13640139/egl-emulation-failed-to-establish-connection-to-host-android) – Usama Saeed US Jan 02 '18 at 03:18
  • I have next error [ERROR:gl_surface_egl.cc(467)] eglChooseConfig failed with error EGL_SUCCESS .what is problem? – Miodrag Trajanovic Dec 26 '19 at 20:28

4 Answers4

2

Try enabling javascript and override the webviewclient to avoid redirection:

        WebView myWebview ;
        myWebview  = (WebView) this.findViewById(R.id.webz);
        myWebview.getSettings().setJavaScriptEnabled(true);
        myWebview.setWebViewClient(new WebViewClient());
        myWebview.loadUrl("https://en.wikipedia.org/");

and update the constraints of your WebView:

   <WebView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:id="@+id/webz"></WebView>
diegoveloper
  • 93,875
  • 20
  • 236
  • 194
0

The problem was with the emulator's graphics I believe as trying @diegoveloper 's solution on the emulator still did not load the page but trying it on an actual android device was successful.

helpmeplease
  • 101
  • 1
  • 1
  • 9
0
  1. Do this
  2. Restart the emulator (as suggested in another post and in the comments of this post)
  3. If that doesn't work, restart your device.

Worked for me.

0

Add activity in your AndroidManifest.xml

android:name="com.(your browser activity)" android:screenOrientation="portrait">