[TIMOB-16249] Android: Web view evalJS is not working on Android versions >= JELLY_BEAN_MR1
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Duplicate |
| Resolution Date | 2014-02-06T18:20:02.000+0000 |
| Affected Version/s | Release 3.2.0 |
| Fix Version/s | Release 3.3.0 |
| Components | Android |
| Labels | andoid, supportTeam |
| Reporter | grebulon |
| Assignee | Hieu Pham |
| Created | 2014-01-19T10:32:28.000+0000 |
| Updated | 2017-03-22T20:44:07.000+0000 |
Description
TiReturn::setValue should be declared with @JavascriptInterface annotation.
File: android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewBinding.java
line: 174
Change the declaration of setValue() to:
@JavascriptInterface
public void setValue(String value)
[~buddyguards] Thanks for suggesting the solution but it would be helpful if you can post a simple test case to demonstrate the problem as well. We would move this ticket to engineering as soon as we are able to reproduce it with a test case.
Very simple:
title will be null. Note that the @JavascriptInterface is required only on late versions of Android. I tested it with 4.3, and as soon as I added the annotation, it started to work.var browser=Titanium.UI.createWebView({top:0,left:0,bottom:0,width:'100%'}); browser.url="http://www.google.com"; var title=browser.evalJS('document.title'); Ti.API.info(title);Moving this ticket to engineering as I can reproduce this issue with the provided test case.
I have noticed the same issue in:
Problem: twitter-adapter cannot work, because the library selects pin from html-page. I think it is urgent to solve it. Unsolved we cannot work with (HTML)-oauth!var win = Ti.UI.createWindow(); var webview = Ti.UI.createWebView({ url : 'http://www.appcelerator.com/', }); win.add(webview); win.open(); webview.addEventListener('load', function(e) { console.log(webview.evalJS('document.title')); });I cannot finf this file in my system: TiWebViewBinding.java
Closing ticket as duplicate of the ticket that is mentioned above and has since been closed.