Note that there are some explanatory texts on larger screens.

plurals
  1. PO@JavascriptInterface cannot be resolved
    text
    copied!<p>I'm working with Android to make a webpage interact with my app. As such, I've gone through the documentation and tutorials and ended up coming up with <a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CDUQFjAA&amp;url=http://developer.android.com/guide/webapps/webview.html&amp;ei=LlH2UKC8FomgqgG4r4HADA&amp;usg=AFQjCNH8Xkqt0eXYVwXwtcD2P-sfM9CUtA&amp;sig2=Vbpk0MlJuRXNgsL3gKK3bQ&amp;bvm=bv.41018144,d.aWM" rel="noreferrer">this site</a>. In it, the developers list that you should include <code>@JavascriptInterface</code> before any function you wish to be accessible by the WebView and that without it, Jelly Bean won't recognize the function.</p> <p>My problem is that when I put that in, I get an error saying:</p> <blockquote> <p>@JavascriptInterface cannot be resolved to a type</p> </blockquote> <p>Without it, my code compiles and works fine, but I want Jelly Bean compatibility. I'm currently working on Android 1.6 as a base, so does it just not have <code>@JavascriptInterface</code>? Is that a Jelly Bean specific thing, meaning I'll have to make a program specifically for Jelly Bean? Any help would be greatly appreciated. Here is my complete interface class:</p> <pre><code>import android.content.Context; public class WebAppInterface{ Context mContext; /** Instantiate the interface and set the context */ WebAppInterface(Context c) { mContext = c; } /** Show a toast from the web page */ //needed for jelly bean @JavascriptInterface public void turnOff() { MyAlarmPopup.turnOff(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload