最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Android: Is there a way to execute JavaScript from my app? - Stack Overflow

programmeradmin0浏览0评论

I was hoping to find something in the Android sdk similar to the javax.script package in Java; but haven't been able to find anything. Am I missing a way to execute JavaScript from my app?

I was hoping to find something in the Android sdk similar to the javax.script package in Java; but haven't been able to find anything. Am I missing a way to execute JavaScript from my app?

Share asked Aug 12, 2011 at 15:47 ab11ab11 20.1k44 gold badges123 silver badges214 bronze badges 3
  • What rights would you expect it to have? What is the script actually doing? – Fantius Commented Aug 12, 2011 at 15:53
  • Why can't you do whatever the script is doing right there in Java? – Fantius Commented Aug 12, 2011 at 15:53
  • I want to be able to let users execute a script. Their scripts will interact with interfaces which I will implement in Java. (that makes sense, right?) – ab11 Commented Aug 12, 2011 at 17:16
Add a ment  | 

4 Answers 4

Reset to default 3

Rhino is a port of JavaScript that is implemented in Java. It can run on Android with minor tweaks. You can find the code for it as part of the SL4A project.

You could embed an invisible browser and have it execute the script. But perhaps there is a better way.

You can execute JavaScript from within a WebView. Make sure you set WebSettings.setJavaScriptEnabled(true).

You can find more information here.

I guess it depends on what you need the JavaScript to do. There is a way to execute JavaScript contained within HTML, ie PhoneGap.

发布评论

评论列表(0)

  1. 暂无评论