0
從JavaScript中存儲的參數我有一個JavascriptInterface在我的Android代碼的setter /吸氣:Android中
mWebView.addJavascriptInterface(new AccessibleMethods(), "Android");
private class AccessibleMethods {
private boolean isWorking;
public void setIsWorking(boolean working)
{
this.isWorking = working;
// A toast message here of this.isWorking displays true
}
public boolean getIsWorking()
{
return this.isWorking;
}
}
在我的JavaScript代碼,我調用該函數:
Android.setIsWorking(true);
但是當我嘗試以另一種方式或在課程外部訪問Java中的工作時,它沒有正確的值。
AccessibleMethods methods = new AccessibleMethods();
methods.getIsWorking(); // returns wrong or no value
我需要這個訪問JavaScript變量onKeyDown。
有什麼建議嗎?
如果您認爲這可以幫助其他人,請保留此;否則,您可以自由刪除它。 – Rajesh