码迷,mamicode.com
首页 > 移动开发 > 详细

[Android]Webview中JS接口调用Java-版本问题

时间:2014-06-20 08:53:36      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:des   android   class   code   java   http   

问题:

The javascript to java bridge on 2.3 Gingerbread is causing crashes.  This is 100% reproducible using the WebViewDemo application from here: http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/Samples/WebViewDemo.
Note: The project file for that app is a little messed up, however, if you recreate the project, keeping the code the same, you can reproduce the error.  The sample is old, but the code should still run as none of these interfaces have been deprecated.

It is also easily reproducible by creating a simple application that creates a webview, enables javascript, adds a JS interface, then loads a script into the webview. The code for this even simpler app is attached as well as WebViewTest and a secondary Test class as the "bridge".

The demos work as expected when using 2.2

This is a serious issue as it will cause crashes for any app using the webview to do any serious work.  Thanks in advance for taking a look at this.

Attached is the output from logcat as well as the output from adb bugreport.
bubuko.com,布布扣 log.txt
8.3 KB   View   Download
bubuko.com,布布扣 bug.txt
1.1 MB   View   Download
bubuko.com,布布扣 WebViewTest.java
764 bytes   View   Download
bubuko.com,布布扣 Test.java
149 bytes   View   Download
 
 
解决方案:
安卓2.3中会有问题,换个target版本启动即可解决。
 
参考:

[Android]Webview中JS接口调用Java-版本问题,布布扣,bubuko.com

[Android]Webview中JS接口调用Java-版本问题

标签:des   android   class   code   java   http   

原文地址:http://www.cnblogs.com/webapplee/p/3771909.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!