[英]Android - cannot acces to actionbar with JavascriptInterface
[英]@JavascriptInterface cannot be resolved
我正在與Android合作,使網頁與我的應用互動。 因此,我已經完成了文檔和教程,最終提出了這個網站 。 在其中,開發人員列出您應該在WebView可以訪問的任何函數之前包含@JavascriptInterface
,如果沒有它,Jelly Bean將無法識別該函數。
我的問題是,當我把它放進去時,我得到一個錯誤說:
@JavascriptInterface無法解析為某個類型
沒有它,我的代碼編譯和工作正常,但我想要Jelly Bean兼容性。 我目前正在使用Android 1.6作為基礎,所以它沒有@JavascriptInterface
嗎? 這是Jelly Bean特有的東西,這意味着我必須專門為Jelly Bean制作一個程序嗎? 任何幫助將不勝感激。 這是我完整的接口類:
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();
}
}
@JavascriptInterface
是在JellyBean中引入的。
您需要將項目構建目標設置為API級別17
從Eclipse IDE,轉到Project->Properties
。 選擇Android並設置目標
APK將適用於舊版本的Android。
適用於Android Studio的用戶的步驟:
import android.webkit.JavascriptInterface;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.