Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16249] Android: Web view evalJS is not working on Android versions >= JELLY_BEAN_MR1

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2014-02-06T18:20:02.000+0000
Affected Version/sRelease 3.2.0
Fix Version/sRelease 3.3.0
ComponentsAndroid
Labelsandoid, supportTeam
Reportergrebulon
AssigneeHieu Pham
Created2014-01-19T10:32:28.000+0000
Updated2017-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)

Comments

  1. Ritu Agrawal 2014-01-20

    [~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.
  2. grebulon 2014-01-20

    Very simple:
       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);
       
    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.
  3. Ritu Agrawal 2014-01-20

    Moving this ticket to engineering as I can reproduce this issue with the provided test case.
  4. Rainer Schleevoigt 2014-01-25

    I have noticed the same issue in:
       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'));
       });
       
    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!
  5. Rainer Schleevoigt 2014-01-25

    I cannot finf this file in my system: TiWebViewBinding.java
  6. Hieu Pham 2014-02-06

  7. Lee Morris 2017-03-22

    Closing ticket as duplicate of the ticket that is mentioned above and has since been closed.

JSON Source