Android preload a url into WebView while splashscreen is showing

前端 未结 2 758
故里飘歌
故里飘歌 2021-02-06 15:41

I have an app with a splash-screen which after a few seconds opens up the main activity that has a WebView. The problem is that, only then, does the main activity start to load

2条回答
  •  耶瑟儿~
    2021-02-06 16:32

    Follow these steps..

    1) set splash layout on your screen.

    2) start a new thread, in this thread inflate a layout that contains webview.

    3) Load url in webView. Set webview Client to webview to know when your page loading completes. There is a quick example. override onPageFinished.

    4) Now break the thread and pass this inflated view to next activity, and set it to setContentView(inflatedView);

    Thanks.

提交回复
热议问题