use of com.telenor.connect.sms.HtmlToAndroidInstructionsInterface in project connect-android-sdk by telenordigital.
the class WebViewHelper method setupWebView.
// 1. HtmlToAndroidInstructionsInterface has no public fields.
// 2. We need JS for the web page.
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" })
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setupWebView(final WebView webView, ConnectWebViewClient client, final String pageToLoad) {
webView.setWebViewClient(client);
webView.setVerticalScrollBarEnabled(true);
webView.setHorizontalScrollBarEnabled(false);
final WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSaveFormData(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
}
webView.addJavascriptInterface(new HtmlToAndroidInstructionsInterface(client), "AndroidInterface");
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
acceptAllCookies(webView);
webView.loadUrl(pageToLoad);
webView.postDelayed(new RepeatingDelayedPageReloader(webView, pageToLoad), WEB_VIEW_TIMEOUT);
}
Aggregations