webview

Android WebView保存Cookie登录

爱⌒轻易说出口 提交于 2020-04-13 00:59:55
因项目需要,需要在App中嵌入网页,使用Nativie方式登录,然后将cookie保存到WebView中,实现免登录功能。同步Cookie到WebView的方法网上有大量的参考资料,也可以参考下面的代码: /** * Sync Cookie */ private void syncCookie(Context context, String url){ try{ Log.d("Nat: webView.syncCookie.url", url); CookieSyncManager.createInstance(context); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.removeSessionCookie();// 移除 cookieManager.removeAllCookie(); String oldCookie = cookieManager.getCookie(url); if(oldCookie != null){ Log.d("Nat: webView.syncCookieOutter.oldCookie", oldCookie); } StringBuilder sbCookie =

Android WebView load https url results in blank screen

落花浮王杯 提交于 2020-04-10 06:17:40
问题 WebView is working fine with http requests and also https where well known Trusted sites like https://www.online.citibank.co.in/ But I try to access private site with CA issued from 3rd party, it is giving blank screen. Certificate is installed to the phone via SD card and listed under trusted certs list. When i tried the same URL using HttpsURLConnection after adding the cert to TrustManager, it is working fine (able to get the content). Following are the code snippet for WebView and

Error inflating class android.webkit.WebView on android 5

落爺英雄遲暮 提交于 2020-04-10 03:41:28
问题 I got the following error testing on Android 5.0 (API 21). Tested on other OS versions works well. java.lang.RuntimeException: Unable to start activity ComponentInfo{...ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class android.webkit.WebView Can't find nothing special about the xml layout, at line 24: <WebView android:id="@+id/nav_fg_legal_detail_web" android:layout_width="match_parent"

Error inflating class android.webkit.WebView on android 5

懵懂的女人 提交于 2020-04-10 03:39:59
问题 I got the following error testing on Android 5.0 (API 21). Tested on other OS versions works well. java.lang.RuntimeException: Unable to start activity ComponentInfo{...ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class android.webkit.WebView Can't find nothing special about the xml layout, at line 24: <WebView android:id="@+id/nav_fg_legal_detail_web" android:layout_width="match_parent"

Swift - programmatically click on point in screen

谁说胖子不能爱 提交于 2020-04-08 18:57:19
问题 tl;dr- How can I programmatically perform a native touch in specific point on the screen? Within the web view there is HTML that contains an Iframe, so the web view code and elements are not accessible and sanding massages to JS is not possible either. There is a button in the web view on specific coordinates. How can I press it programmatically? 回答1: To simulate the touch you will need to write a javascript function in your web page that can click the button on your behalf. Let's assume the

How to get the full height of in android WebView?

。_饼干妹妹 提交于 2020-04-08 09:57:35
问题 I have a RelativeLayout with WebView . I am loading some generated html text into that WebView . After loading the data WebView height exceeding the screen. Now I need the height of the entire WebView . Till now I tried WebView#getHeight() , WebView#getBottom() but I'm getting the height of visible content. How to get the total height of WebView .? 回答1: Finally I got the answer for my question. Here is the answer. After loading WebView we will get call in WebViewClient#onPageFinished there we

WebView with an IFRAME android

天涯浪子 提交于 2020-04-07 15:32:29
问题 I want to load an HTML <IFRAME> inside an WebView , but I don't know why, it is not able to do so. I am using following code to load <IFRAME> webView.loadData("<iframe src=\"http://www.google.com\"></iframe>", "text/html", "utf-8"); Here's what I have tried. WebSettings webViewSettings = webView.getSettings(); webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true); webViewSettings.setJavaScriptEnabled(true); webViewSettings.setPluginsEnabled(true); webViewSettings

Android 上显示 PDF 文件

让人想犯罪 __ 提交于 2020-04-06 17:29:22
使用 WebView 配合 pdf.js 在 Android 上显示 PDF 文件 最近在 手机上要显示 PDF 文件,在搜索引擎上找到了很多方案,大体上有以下几种: 使用提供的在线服务,例如 Google 文档预览服务,mWebView.loadUrl(" http://docs.google.com/gview?embedded=true&url= "+ pdfUrl); 使用 AndroidPdfViewer,这是一个 GitHub 上开源的库,除了体积大点别的都挺好, https://github.com/barteksc/AndroidPdfViewer 使用 Moliza 开源的 Pdf.js 这个库是很强大的,配合 WebView ,可以支持预览,缩放,翻页等等功能 使用 腾讯浏览服务 https://x5.tencent.com/ 我是选择了 pdf.js 这个库,使用 WebView 配合 H5 页面,可以做到随意的自定义,并且体积很小,放在服务器的话就更小了。 使用资源: https://github.com/mozilla/pdf.js 版本 版本是 2.3.200 在这里记录下使用的过程也方便后来者。 考虑到网络不稳定的情况,所以我把 js 库下载下来了,不介意的可以直接使用网络库 https://www.jsdelivr.com/package/npm

Flutter webview two way communication

六月ゝ 毕业季﹏ 提交于 2020-04-06 03:20:48
问题 I have an html file that I am loading in Flutter webview using flutter_webview_plugin. I am using evalJavascript to call function in my javascript code, meaning flutter(dart)->js. However, I also need some way to communicate back something to flutter(dart) layer, meaning js->flutter(dart). I have tried using - webkit.messageHandlers.native - window.native to support both platforms(Android,iOS) checking if those are available in JS. But, those comes as undefined. Using following code to get

js判断是安卓 还是 ios webview?

天大地大妈咪最大 提交于 2020-04-01 07:47:26
通过判断浏览器的userAgent,用正则来判断是否是 ios 和 Android 客户端。 代码 如下: <script type="text/javascript"> var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 alert('是否是Android:'+isAndroid); alert('是否是iOS:'+isiOS); </script> 可以打开你的 Android 手机或者 iphone 扫描看看 下面一个比较全面的浏览器检查函数,提供更多的检查内容,你可以检查是否是移动端( Mobile )、ipad、iphone、微信、QQ等。 第一种:来自http://blog.baiwand.com/?post=176 <script type="text/javascript"> //判断访问终端 var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion;