Home > Enterprise >  On image click open URL in new browser not in the old webview
On image click open URL in new browser not in the old webview

Time:01-31

I'm loading URL on the webview with image

webView.loadUrl(url)

and I'm waiting then URL will finished

webView.webViewClient = object : WebViewClient() {
     override fun onPageFinished(view: WebView, url: String) {
         view.visibility = View.VISIBLE
         //do some staff          
     }
}

but then I'm clicking on the image, new link must be open, but I need to open it in new browser not in this webview. If I'm using without onPageFinished it does, but I need this onPageFinished. How can I open new URL on the image click in new browser?

CodePudding user response:

override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
       val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
       context.startActivity(intent)
       return true
}
    
  •  Tags:  
  • Related