How to fix Blankwebview in Android studio

Issue

I just made a simple webview and it works perfectly fine when I use the URL as www.google.com but when I put my own URL it doesn’t show up on the app instead it said you needed JavaScript to run this app. I enabled Java script and now there is nothing shown in the app. Here’s my code:

package com.------;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

    private WebView Browser;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Browser  (WebView) findViewById(R.id.webview);
        Browser.setWebViewClient(new WebViewClient());
        Browser.loadUrl("-----");

        WebSettings webSettings1  Browser.getSettings();
        webSettings1.setJavaScriptEnabled(true);

    }

and manifest:

<?xml version"1.0" encoding"utf-8"?>
<manifest xmlns:android"http://schemas.android.com/apk/res/android"
    package"com.---------------">


    <uses-permission android:name"android.permission.INTERNET"/>
    <uses-permission android:name"android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name"android.permission.ACCESS_WIFI_STATE"/>
    <application
        android:allowBackup"true"
        android:icon"@mipmap/ic_launcher"
        android:label"@string/app_name"
        android:roundIcon"@mipmap/ic_launcher_round"
        android:supportsRtl"true"
        android:theme"@style/AppTheme">
        <activity android:name".MainActivity">
            <intent-filter>
                <action android:name"android.intent.action.MAIN" />

                <category android:name"android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

nd the error:

38:36.242 10536-10536/? E/------: Unknown bits set in runtime_flags: 0x8000
2020-09-11 22:38:36.777 10536-10572/com---------- E/ion: ioctl c0044901 failed with code -1: Invalid argument

Solution

your code is fine as i can see and you said that (it works perfectly fine when I use the URL as www.google.com) that tell you the problem is in your web site not in the web view it’s look like your website need a java script and i think you have to use a browser java script engine not web view engine chrome java script engine as example

to use chrome java script engine you can use Chrome Custom Tabs to open an chrome tab on your app Chrome Custom Tabs allow an app to customize how Chrome looks and feels. An app can change things like:

Toolbar color Enter and exit animations Add custom actions to the Chrome toolbar, overflow menu and bottom toolbar The WebView is good solution if you are hosting your own content inside your app. If your app directs people to URLs outside your domain, i recommend that you use Chrome Custom Tabs A complete example is available at https://github.com/GoogleChrome/custom-tabs-client. It contains re-usable classes to customize the UI,

Answered By – Sideeg MoHammed

Leave a Comment