-
- All Implemented Interfaces:
-
org.chromium.support_lib_boundary.FeatureFlagHolderBoundaryInterface,org.chromium.support_lib_boundary.WebViewClientBoundaryInterface
public class SingpassWebViewClient extends WebViewClientCompat
Webview client which will automatically handle Singpass links and launch Singpass app. Extend this class and run the super method in
shouldOverrideUrlLoading.Example usage below
// create your WebViewClient by inheriting from SingpassWebViewClient class CustomWebViewClient extends SingpassWebViewClient { // For devices api 21 and above @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { boolean handled = super.shouldOverrideUrlLoading(view, request); // if handled == true, means that url can be opened by Singpass app if (handled) { // return true to signal to webview that url is being handled already return true; } // if handled == false, means that url is NOT a Singpass app url else { // do your own handling if needed ... your own handling code for any other urls ... // return true if you have handled and urls yourself // or false if webview should proceed to handle it by default return false; } } // override this function only if you need to handle devices api 19 to 20 // this will ONLY be called on devices api 20 and below @Override public boolean shouldOverrideUrlLoading(@Nullable WebView view, @Nullable String url) { boolean handled = super.shouldOverrideUrlLoading(view, request); // if handled == true, means that url can be opened by Singpass app if (handled) { // return true to signal to webview that url is being handled already return true; } // if handled == false, means that url is NOT a Singpass app url else { // do your own handling if needed ... your own handling code for any other urls ... // return true if you have handled and urls yourself // or false if webview should proceed to handle it by default return false; } } } // in your activity or fragment WebView webView = findViewById(R.id.wvWebview); webView.setWebViewClient(new CustomWebViewClient());
-
-
Constructor Summary
Constructors Constructor Description SingpassWebViewClient()
-
Method Summary
-
Methods inherited from class androidx.webkit.WebViewClientCompat
onReceivedError, onTooManyRedirects, shouldInterceptRequest -
Methods inherited from class sg.ndi.sp.webview.SingpassWebViewClient
getSupportedFeatures, onReceivedError, onReceivedError, onSafeBrowsingHit, onSafeBrowsingHit -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
shouldOverrideUrlLoading
Boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
-
shouldOverrideUrlLoading
Boolean shouldOverrideUrlLoading(WebView view, String url)
-
onPageStarted
Unit onPageStarted(WebView view, String url, Bitmap favicon)
-
onPageFinished
Unit onPageFinished(WebView view, String url)
-
onLoadResource
Unit onLoadResource(WebView view, String url)
-
shouldInterceptRequest
WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request)
-
onFormResubmission
Unit onFormResubmission(WebView view, Message dontResend, Message resend)
-
doUpdateVisitedHistory
Unit doUpdateVisitedHistory(WebView view, String url, Boolean isReload)
-
onReceivedSslError
Unit onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
-
onReceivedClientCertRequest
Unit onReceivedClientCertRequest(WebView view, ClientCertRequest request)
-
onReceivedHttpAuthRequest
Unit onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm)
-
shouldOverrideKeyEvent
Boolean shouldOverrideKeyEvent(WebView view, KeyEvent event)
-
onUnhandledKeyEvent
Unit onUnhandledKeyEvent(WebView view, KeyEvent event)
-
onScaleChanged
Unit onScaleChanged(WebView view, Float oldScale, Float newScale)
-
onReceivedLoginRequest
Unit onReceivedLoginRequest(WebView view, String realm, String account, String args)
-
onRenderProcessGone
Boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail)
-
onReceivedError
Unit onReceivedError(WebView view, WebResourceRequest request, WebResourceErrorCompat error)
-
onPageCommitVisible
Unit onPageCommitVisible(WebView view, String url)
-
onReceivedHttpError
Unit onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse)
-
onSafeBrowsingHit
Unit onSafeBrowsingHit(WebView view, WebResourceRequest request, Integer threatType, SafeBrowsingResponseCompat callback)
-
-
-
-