Android utilize V8 without WebView

后端 未结 5 857
甜味超标
甜味超标 2020-12-12 13:55

I\'m exercising executing javascript from Java. Rhino works very well for this on desktop, but has to fall back to (slow) interpreted mode on Android (due to dalvik being u

5条回答
  •  暖寄归人
    2020-12-12 14:20

    Can you get a hold of the Context that is your Application? There are a couple ways to do this.

    1. Call getApplication() from your Activity (Application is a child of Context)
    2. Call getApplicationContent() from a Context (Context likely being your Activity)

    UPDATE

    According to this Android documentation, your bound Javascript code will run in a separate process anyways, so there should be no need to set it up in its own Thread.

    From the link:

    Note: The object that is bound to your JavaScript runs in another thread and not in the thread in which it was constructed. (The 'object' being referred to is the JavascriptInterface class)

提交回复
热议问题