Android应用程序未在emulator上连接到internet
应用程序未连接到internet。我有Android应用程序未在emulator上连接到internet,android,network-connection,Android,Network Connection,应用程序未连接到internet。我有 <uses-permission android:name="android.permission.INTERNET" /> 这是我的主要活动 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<uses-permission android:name="android.permission.INTERNET" />
这是我的主要活动
<?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>
尝试启用javascript并覆盖webviewclient以避免重定向:
WebView myWebview ;
myWebview = (WebView) this.findViewById(R.id.webz);
myWebview.getSettings().setJavaScriptEnabled(true);
myWebview.setWebViewClient(new WebViewClient());
myWebview.loadUrl("https://en.wikipedia.org/");
并更新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的解决方案仍然没有加载页面,但在实际的android设备上尝试成功 按照这里的建议重新启动仿真器我有下一个错误[error:gl_surface_egl.cc(467)]eglChooseConfig失败,错误为egl_SUCCESS。问题是什么?
WebView myWebview ;
myWebview = (WebView) this.findViewById(R.id.webz);
myWebview.getSettings().setJavaScriptEnabled(true);
myWebview.setWebViewClient(new WebViewClient());
myWebview.loadUrl("https://en.wikipedia.org/");
<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>