DEV Community

HarmonyOS
HarmonyOS

Posted on

[Smart Watch] [API 6] How to resolve the issue of a white screen appearing when loading a webpage in a webview?

Read the original article:[Smart Watch] [API 6] How to resolve the issue of a white screen appearing when loading a webpage in a webview?

Issue

When loading a webpage in a webview, a white screen may appear.

Solution

WebView.setBrowserAgent(new BrowserAgent(this) {

    @Override
    public void onProgressUpdated(WebView webview, int newProgress) {
        super.onProgressUpdated(webview, newProgress);

        mProgressBar.setProgressValue(newProgress);
        if (newProgress == 100 && mStatus == WEBVIEW) {
            showWebView();
        } else if (mStatus == WEBERROR) {
            showWebError();
        } else if (mStatus == NONETWORK) {
            showNoNetwork();
        }
    }
});
Enter fullscreen mode Exit fullscreen mode

Written by Jeorge Kiryienko

Top comments (0)