Evaluate a javascript string from within android

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Evaluate a javascript string from within android

Postby bennyb » Wed Sep 23, 2009 9:41 pm

Is it possible to evaluate a javascript string expression from within an android app?

Normally in java, you will do something like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         ScriptEngineManager manager = new ScriptEngineManager();
  3.  
  4.         ScriptEngine engine = manager.getEngineByName("js");
  5.  
  6.        
  7.  
  8.         try {
  9.  
  10.             String expression = "3+4";
  11.  
  12.             Object result = engine.eval(expression);
  13.  
  14.             System.out.println(expression+" = "+result);
  15.  
  16.         } catch(ScriptException se) {
  17.  
  18.             se.printStackTrace();
  19.  
  20.         }
  21.  
  22.  
  23.  
  24. /*
  25.  
  26.     output: 3+4 = 7.0
  27.  
  28. */
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Is this possible in android?
bennyb
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed Sep 23, 2009 4:45 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests