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 this site. In it, the developers list that you should include @JavascriptInterface
before any function you wish to be accessible by the WebView and that without it, Jelly Bean won't recognize the function.
My problem is that when I put that in, I get an error saying:
@JavascriptInterface cannot be resolved to a type
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 @JavascriptInterface
? 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:
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();
}
}