Issue
WebView WebDimrah;
WebSettings WebSettingDimrah;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebDimrah = (WebView)findViewById(R.id.WebView1);
WebSettingDimrah = WebDimrah.getSettings() ;
WebDimrah.setWebViewClient(new WebViewClient());
WebDimrah.getSettings().setJavaScriptEnabled(true);
WebDimrah.loadUrl("https://facebook.com");
Hello, I have problem, I have a home work to make web view with android studio, and I type url facebook, than I run it, but it's just like that
I have a permission on my manifest, but in my avd still Webpage Not available
Logcat:
11-17 19:16:06.535 5829-5829/com.dimrahwebkit E/dalvikvm: Could not find class 'androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper', referenced from method androidx.core.view.ViewCompat.addOnUnhandledKeyEventListener
11-17 19:16:06.535 5829-5829/com.dimrahwebkit E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.dispatchApplyWindowInsets
11-17 19:16:06.545 5829-5829/com.dimrahwebkit E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.onApplyWindowInsets
11-17 19:16:06.545 5829-5829/com.dimrahwebkit E/dalvikvm: Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method androidx.core.view.ViewCompat.removeOnUnhandledKeyEventListener
11-17 19:16:06.545 5829-5829/com.dimrahwebkit E/dalvikvm: Could not find class 'androidx.core.view.ViewCompat$1', referenced from method androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener
11-17 19:16:06.585 5829-5829/com.dimrahwebkit E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method androidx.appcompat.widget.AppCompatImageHelper.hasOverlappingRendering
11-17 19:16:06.975 5829-5829/com.dimrahwebkit E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
11-17 19:16:06.975 5829-5829/com.dimrahwebkit E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
11-17 19:16:06.975 5829-5829/com.dimrahwebkit E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
11-17 19:16:07.255 5829-5829/com.dimrahwebkit E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
11-17 19:16:07.255 5829-5829/com.dimrahwebkit E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
11-17 19:16:07.255 5829-5829/com.dimrahwebkit E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
11-17 19:16:07.255 5829-5829/com.dimrahwebkit E/EGL_emulation: tid 5829: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH)```
Solution
You need to override
the onReceivedSslError()
method of the WebViewClient
for the webpage to display. Here is what your code should look like :
private WebView WebDimrah;
private WebSettings WebSettingDimrah;
@SuppressLint("SetJavaScriptEnabled")
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebDimrah = (WebView)findViewById(R.id.WebView1);
WebSettingDimrah = WebDimrah.getSettings() ;
WebDimrah.getSettings().setJavaScriptEnabled(true);
WebDimrah.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
});
WebDimrah.loadUrl("https://facebook.com");
}
Also, in your Android.xml
file (manifest) add this line:
android:usesCleartextTraffic="true"
inside the ... tag.
Answered By - Mayokun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.