webview

android webview pdf viewing

强颜欢笑 提交于 2020-01-12 10:11:12
问题 im building an app that should allow users to click a link to a pdf document in a webview and display it in the view. im using google docs viewing pdf files work, but my problem is that i only want the method to work for pdf links and not every link, heres my code: public class HelloWebViewActivity extends Activity { WebView mWebView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView

android webview pdf viewing

我的未来我决定 提交于 2020-01-12 10:10:29
问题 im building an app that should allow users to click a link to a pdf document in a webview and display it in the view. im using google docs viewing pdf files work, but my problem is that i only want the method to work for pdf links and not every link, heres my code: public class HelloWebViewActivity extends Activity { WebView mWebView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView

Is there a way to pre-cache a web page for viewing with an Android WebView?

孤街浪徒 提交于 2020-01-12 07:31:30
问题 I've read about the HTML5 cache manifest, and I've seen Android does support caching websites using the cache manifest. I want to use the cache manifest to download all the required resources for my website to preload it, and then open a WebView and display the remote website using the pre-cached resources. I want to pre-cache my remote page somehow, preferably without using a WebView for the caching process. The problem with using a WebView for the pre-caching process is that loading the

Android Web-view Error I/chromium: [INFO:CONSOLE(1)] "Uncaught ReferenceError:

江枫思渺然 提交于 2020-01-12 07:15:26
问题 I have a web-service In that I have added bar-code reader for android So with the Help of JavaScript I am calling my bar-code reader from web-view So for that I followed this and designed on server side... I have Given this at JavaScript function mybarcd() { MyApp.mybarcdt(); } function actfromAnd(msg){ document.getElementById("brcd").value = msg; } at HTML/PHP <div class="data"> <input id="brcd" type="text" value=""/> <button type="button" onClick="mybarcd()">SCAN</button> </div> On Android

Android WebView总结

做~自己de王妃 提交于 2020-01-12 07:12:38
1、添加权限:AndroidManifest.xml中必须使用许可"android.permission.INTERNET",否则会出Web page not available错误。 在Androidmanifest.xml文件中添加 <uses-permission android:name="android.permission.INTERNET" /> </manifest> 2、在要Activity中生成一个WebView组件:WebView webView = new WebView(this); 3、设置WebView基本信息: 如果访问的页面中有Javascript,则webview必须设置支持Javascript。 webview.getSettings().setJavaScriptEnabled(true); 触摸焦点起作用 requestFocus(); 取消滚动条 this.setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY); 4、设置WevView要显示的网页: 互联网用:webView.loadUrl("http://www.google.com"); 本地文件用:webView.loadUrl( file:///android_asset/xx.html );固定格式    本地文件存放在:assets文件中

【android内存泄露】 WebView篇

五迷三道 提交于 2020-01-12 04:41:23
在咱的博客园app里 ,新闻的内容使用WebView展示的。在测试中,咱重复进入、退出某个新闻10多次,观察到 Objects一直在不断增长,反复触发GC,但是一直回收不了,占用的内存越来越高,于是警觉到这个WebView可能泄露内存了 如下: 在StackOverFlow上搜了下android webview memory leak(国内搜索结果质量太差,新手朋友推荐去这个网站搜答案) 里面有个回答大概的意思是: 我们在xml里面定义的WebView标签, 默认这个Activity就被这个webView作为Context参数所持有了 ,因此,当这个Activity结束了想释掉放自己时,但是任然被webView所引用,因此GC回收不了,造成内存泄露 解决之道就是 1: 使用容器包裹WebView <FrameLayout android:id="@+id/web_container" android:layout_width="fill_parent" android:layout_height="wrap_content"/> 2:手动创建WebView,使用ApplicationContext作为参数。在Ondestroy,调用容器的removeAllViews,同时调用webView的 destroy public class TestActivity extends

How does the Gmail Android app do the webview-header-overlay magic for the mail-conversation view?

こ雲淡風輕ζ 提交于 2020-01-12 04:00:30
问题 Using hierarchyviewer on the Gmail conversation view shows an interesting and unusual layout hierarchy: All messages in a single conversation are rendered in a single WebView (specifically a com.google.android.gm.CustomWebView , seen on the left). Only the body of the messages is rendered - the spaces where the headers would go are left blank . On top of the WebView is overlaid a com.google.android.gm.MessageHeaderScrollView (seen on the right) which uses a HybridConversationScrollContainer

Android中Webview使用自定义的javascript进行回调

风流意气都作罢 提交于 2020-01-12 03:46:19
先说为什么需要讨论这个问题。 现在很多的手机应用,都可能会直接嵌入一个web页面。这样做的好处:一个是功能更新方便,维护起来容易,只需要维护服务器的页面即可,不需要更新客户端;另一个是功能通用,不仅android可以用,ios也可以用,symbian也可以直接用。 那为什么现在很多手机应用并不做成web方式的呢?原因很多。一个是现阶段web方式展现能力相对较弱,如果对于应用的美观程度要求比较高,就无法使用web方式;一个是web方式速度相对较慢,用户体验会受一些影响;一个是现阶段流量还是相对宝贵,web方式流量相对较大;还有一个就是有一些功能无法使用web方式实现(关于这一点,现在又很多开源的项目可以实现手机的一些硬件功能,比如拍照啊,获取通讯录啊,都是可以的,感兴趣的可以搜索一下phoneGap。但是从现有的反馈来看,速度较慢,体验较差)。 基于以上的原因,现在很多项目会把一部分功能做成web方式的,一部分功能用其它控件来写。这就需要web页面与其它控件做一些交互。如何交互呢,就是利用自定义的javascript。 下面虚拟一个场景。 现在有一个功能,展现当前用户的好友列表,好友列表页是web方式的,点击某好友的头像以后,进入该好友的详情页面,而这个页面呢,由于某些原因,没做成web方式的。 假设好友列表页是UserListActivity,包含一个webview

Android webview custom error page

老子叫甜甜 提交于 2020-01-12 03:31:13
问题 I am creating application that use WebView to access a online website. I am stuck where I have to add code to check availability of page. public class SpartanWeb extends Activity { WebView mWebView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Adds Progrss bar Support this.getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.main); // Makes Progress bar Visible

webview知多少?

走远了吗. 提交于 2020-01-11 23:21:11
原生页面不会用到webview,html页面内嵌APP,才会用到webview。 一、什么是webview? WebView是手机中内置了一款高性能 webkit 内核浏览器,在 SDK 中封装的一个组件。没有提供地址栏和导航栏,WebView只是单纯的展示一个网页界面。 二、为什么嵌入APP的html页面加载很慢? 1、加载资源的速度不慢,但是资源多了,就很慢。图片、 css 、 js 、 html 这些资源每个大概需要 10-200ms,一般都是 30ms 就 ok 了。如果一个页面上的资源很多,就很浪费时间。 2、能用 css 的地方都用 css ,能直接写到 html 上的就不用 js 动态生成。 3、Webview 加载页面的顺序是这样的:先加载 html ,然后从里面解析出 css 、 js 文件和页面上写死的图片资源进行加载,如果 webkit 的缓存里面有,就不加载。加载完这些资源之后,就进行 css 的渲染和 js 的执行。 Css 的渲染一般不需要很长时间,几十毫秒就 ok 。关键是 js的执行,如果用了 jQuery ,则执行起来需要 5-6 秒。而在这段时间,如果不在 webview 里设置背景,网页部分是白色的,很难看,这是一个很糟糕的用户体验。所以如果用网页布局程序,最好别用很大的 js 框架。 来源: https://www.cnblogs.com