Handle redirection

This commit is contained in:
Benoit Marty 2019-06-18 17:46:52 +02:00
parent 9d3a8e7c40
commit 8ff6fbb153
1 changed files with 6 additions and 1 deletions

View File

@ -20,6 +20,7 @@ package im.vector.riotredesign.core.utils
import android.content.Context import android.content.Context
import android.webkit.WebView import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
/** /**
@ -29,9 +30,13 @@ import androidx.appcompat.app.AlertDialog
*/ */
fun Context.displayInWebView(url: String) { fun Context.displayInWebView(url: String) {
val wv = WebView(this) val wv = WebView(this)
// Set a WebViewClient to ensure redirection is handled directly in the WebView
wv.webViewClient = WebViewClient()
wv.loadUrl(url) wv.loadUrl(url)
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setView(wv) .setView(wv)
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.show() .show()
} }