How to get loaded web page title in Android WebView?

前端 未结 7 736
我在风中等你
我在风中等你 2020-12-01 02:00

I\'m using a WebView in my application, I have a requirement to change the app title based on the page user is on. How can I do this in Android WebView?

I did this i

7条回答
  •  不知归路
    2020-12-01 02:39

    What if you do not want the whole title, and just a Domain Name, Like if you want to show only 'Google' from www.google.com, and you have all the query parameters in this title.

        URL hostUrl= new URL(webView.getUrl());
        String title = hostUrl.getHost();
        title = title.startsWith("www.") ? title.substring(4) : title;
    

提交回复
热议问题